Objects that can be created with CoCreateInstance must also be registered with the system. For these objects, registration maps a CLSID to the Automation component file (.dll or .exe) in which the object resides. The CLSID also maps an ActiveX object back to its application and ProgID.
The following figure shows how registration connects ProgIDs, CLSIDs, and ActiveX components.
The type library can be obtained from its CLSID using the following syntax:
\CLSID\TypeLib = {UUID of type library}
The following syntax indicates that the server is an ActiveX component:
\CLSID\Programmable
The following shows the resulting example code; these COM class registry keys are required:
HKEY_CLASSES_ROOT\CLSID\{F37C8061-4AD5-101B-B826-00DD01103DE1} = Hello 2.0 Application
HKEY_CLASSES_ROOT\CLSID\{F37C8061-4AD5-101B-B826-00DD01103DE1}\ProgID = Hello.Application.2
HKEY_CLASSES_ROOT\CLSID\{F37C8061-4AD5-101B-B826-00DD01103DE1}\VersionIndependentProgID = Hello.Application
HKEY_CLASSES_ROOT\CLSID\{F37C8061-4AD5-101B-B826-00DD01103DE1}\LocalServer32 = hello.exe /Automation
HKEY_CLASSES_ROOT\CLSID\{F37C8061-4AD5-101B-B826-00DD01103DE1}\TypeLib = {F37C8060-4AD5-101B-B826-00DD01103DE1}
HKEY_CLASSES_ROOT\CLSID\{F37C8061-4AD5-101B-B826-00DD01103DE1}\Programmable
The registration file uses the following syntax for each class of each object that the application exposes.
\CLSID\{UUID} = human_readable_string
\CLSID\{UUID}\ProgID = AppName.ObjectName.VersionNumber
\CLSID\{UUID}\VersionIndependentProgID = AppName.ObjectName
\CLSID\{UUID}\LocalServer[32] = filepath[/Automation]
\CLSID\{UUID}\InProcServer[32] = filepath[/Automation]
The ProgID and VersionIndependentProgID are used by other programmers to gain access to the objects you expose. These identifiers (IDs) should use consistent naming guidelines across all your applications as follows:
Version-independent names consist of an AppName.ObjectName, without a version number. For example, Word.Document
or Excel.Chart
.
Version-dependent names consist of an AppName.ObjectName.VersionNumber, such as Excel.Application.5
.
The filepath you register should give the full path and name. Applications should not rely on the MS-DOS PATH variable to find the object.