Microsoft KB Archive/139216

From BetaArchive Wiki
Knowledge Base


BUG: 16-bit Custom Handler Not Loaded If 32-bit Handler Found

Article ID: 139216

Article Last Modified on 12/3/2003



APPLIES TO

  • Microsoft OLE 4.0, when used with:
    • Microsoft Windows NT 3.51 Service Pack 5
    • Microsoft Windows NT 4.0
    • Microsoft Windows 95



This article was previously published under Q139216

SYMPTOMS

An OLE object that provides a custom handler and needs to be embedded in 16- and 32-bit containers must provide a 16-bit and a 32-bit implementation of the handler. When such an object is created in a 16-bit container, the OleCreate function or its variant will return CO_E_ERRORINDLL.

CAUSE

An OLE object with 16-bit and 32-bit implementations of a custom handler will register the handlers as follows:

   HKEY_CLASSES_ROOT\CLSID\{...}\InProcHandler32 = HNDLR32.DLL
   HKEY_CLASSES_ROOT\CLSID\{...}\InProcHandler = HNDLR16.DLL
                

Hndlr32.dll is the 32-bit implementation of the handler and Hndlr16.dll is the 16-bit implementation of the handler.

OleCreate or its variants are supposed to load the 16-bit handler in a 16-bit container and the 32-bit handler in a 32-bit container. Because of a problem in OLE, the 16-bit handler is not loaded if a 32-bit handler is found in the registry. Consequently a 16-bit container will not be able to create the object. However a 32-bit container will be able to create the object.

The 16-bit container will be able to create the object if the InProcHandler32 registration is removed, but then a 32-bit container will not be able to create the object.

RESOLUTION

Register the handler as an in-process server instead of a handler as follows:

   HKEY_CLASSES_ROOT\CLSID\{...}\InProcServer32 = HNDLR32.DLL
   HKEY_CLASSES_ROOT\CLSID\{...}\InProcServer = HNDLR16.DLL
                

The handler will work correctly even though it is registered as an in-process server.

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This was corrected for build 1264. The same fixes have been applied to the Nashville version of OLE32.


Additional query words: 2.00 4.00 kbbuglist

Keywords: kbbug KB139216