When you create an IDLcomIDispatch object, IDL automatically creates a dynamic subclass of the IDLcomIDispatch class to contain the COM object. IDL determines which COM object to instantiate by parsing the class name you provide to the OBJ_NEW function. You specify the COM object to use by creating a class name that combines the name of the base class (IDLcomIDispatch) with either the COM class identifier or the COM program identifier for the object. The resulting class name looks like
IDLcomIDispatch$ID_type$ID
where ID_type is one of the following:
- CLSID if the object is identified by its COM class ID
- PROGID if the object is identified by its COM program ID
and ID is the COM object’s actual class or program identifier string.
While COM objects incorporated into IDL are instances of the dynamic subclass created when the COM object is instantiated, they still expose the functionality of the class IDLcomIDispatch, which is the direct superclass of the dynamic subclass. All IDLcomIDispatch methods are available to the dynamic subclass.
Class Identifiers
A COM object’s class identifier (generally referred to as the CLSID) is a 128-bit identifying string that is guaranteed to be unique for each object class. The strings used by COM as class IDs are also referred to as Globally Unique Identifiers (GUIDs) or Universally Unique Identifiers (UUIDs). It is beyond the scope of this section to discuss how class IDs are generated, but it is certain that every COM object has a unique CLSID.
COM class IDs are 32-character strings of alphanumeric characters and numerals that look like this:
{A77BC2B2-88EC-4D2A-B2B3-F556ACB52E52}
The above class identifier identifies the RSIDemoComponent class included with IDL.
When you create an IDLcomIDispatch object using a CLSID, you must modify the standard CLSID string in two ways:
- You must omit the opening and closing braces ( { } ).
- You must replace the dash characters ( - ) in the CLSID string with underscores ( _ ).
See Creating IDLcomIDispatch Objects for example class names supplied to the OBJ_NEW function.
Program Identifiers
A COM object’s program identifier (generally referred to as the PROGID) is a mapping of the class identifier to a more human-friendly string. Unlike class IDs, program IDs are not guaranteed to be unique, so namespace conflicts are possible. Program IDs are, however, easier to work with; if you are not worried about name conflicts, use the identifier you are most comfortable with.
Program IDs are alphanumeric strings that can take virtually any form, although by convention they look like this:
PROGRAM.Component.version
For example, the RSIDemoComponent class included with IDL has the following program ID:
RSIDemoComponent.RSIDemoObj1.1
When you create an IDLcomIDispatch object using a PROGID, you must modify the standard PROGID string by replacing the dot characters ( . ) with underscores ( _ ).
See Creating IDLcomIDispatch Objects for example class names supplied to the OBJ_NEW function.