Registry Overwritten with Same ProgID/Different Bitness ServerID: Q145676
|
On a single machine, developing and using 16-bit and 32-bit OLE servers
that provide objects with the same ProgID may cause problems if no
compatible server is specified. Some registry entries will point only to
the last server registered and only this server may be accessible from OLE
Automation clients.
This article illustrates why this behavior occurs, and also explains how to
avoid this problem.
Two of the most important keys that are created by registration of an OLE
server are a ProgID key and a CLSID key. The ProgID is created immediately
beneath the HKEY_CLASSES_ROOT predefined key and consists of the
ProjectName.ClassName for a Visual Basic OLE server. The single key created
beneath this ProgID key is named CLSID; its value is a 64-bit number that
is used by OLE to uniquely identify the particular object. In addition to
the ProgID and file extension keys off of HKEY_CLASSES_ROOT, there is also
a key just named CLSID. Expanding this key will show subkeys for each CLSID
that is registered on the machine. There will be a key with the same 64-bit
number associated with the ProgID in this section. Keys underneath this
individual CLSID hold information that OLE uses to access the server.
When classes provided by a 32-bit out-of-process (EXE) OLE server are
registered, two of the keys created beneath the CLSID for each class are
named LocalServer32 and InprocHandler32. Registration of a 16-bit server
causes the creation of LocalServer and InprocHandler keys. The
InprocHandler key specifies the OLE DLL to be used by the client for
communication with the server. The DLL used by local Visual Basic OLE
servers is OLE2.DLL on 16-bit machines, and OLE32.DLL on 32-bit Windows
operating systems. The LocalServer(32) key contains the path and filename
of the executable for the server. With an out-of-process server created
with Visual Basic, this will be the executable generated by Visual Basic.
The problem addressed by this article occurs when 16-bit and 32-bit
versions of an OLE server are registered and provide objects with the same
ProgID but different CLSIDs. This can easily happen if, for example, a 16-
bit OLE server project is loaded into the 32-bit version of Visual Basic
and a new 32-bit executable is created. Starting with a fresh machine,
registering (via compilation perhaps) a 32-bit server will create these
registry entries (among others):
HKEY_CLASSES_ROOT\ProjectName.ClassNameand
HKEY_CLASSES_ROOT\ProjectName.ClassName\CLSID = <CLSID for 32-bit server>
HKEY_CLASSES_ROOT\CLSID\<CLSID for 32-bit server>
HKEY_CLASSES_ROOT\CLSID\<CLSID for 32-bit server>\LocalServer32
HKEY_CLASSES_ROOT\ProjectName.ClassNameand
*HKEY_CLASSES_ROOT\ProjectName.ClassName\CLSID = <CLSID for 16-bit server>
*HKEY_CLASSES_ROOT\CLSID\<CLSID for 16-bit server>
*HKEY_CLASSES_ROOT\CLSID\<CLSID for 16-bit server>\LocalServer
HKEY_CLASSES_ROOT\CLSID\<CLSID for 32-bit server>
HKEY_CLASSES_ROOT\CLSID\<CLSID for 32-bit server>\LocalServer32
Instancing: 2 - Creatable Multiuse
Name: TestClass
Public: True
Public MyVar As Integer
If development of both 16-bit and 32-bit servers is done on the same
machine, this problem can be avoided by specifying a compatible server for
your OLE server project. If a compatible server exists, the CLSID from the
compatible server will be used when any new executable is created. In the
above scenario, this means that only one key CLSID will be used for the
server. Instead of one CLSID possessing a LocalServer key and another
containing a LocalServer32 key, both LocalServer and LocalServer32 keys
will exist beneath the same CLSID. When more than one server is listed
beneath a CLSID, OLE has a predefined order that is used to determine which
server is used to provide the object.
Additional query words: kbVBp400 kbdss kbVBp kbDSupport kbRegistry
Keywords :
Version : 4.00
Platform : NT WINDOWS
Issue type :
Last Reviewed: June 8, 1999