Bridges > COM Import Bridge and ActiveX > COM Import Bridge > IDLcomIDispatch Object Naming Scheme

# IDLcomIDispatch Object Naming Scheme

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.

Note: 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 chapter 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:

1. You must omit the opening and closing braces ( { } ).
2. 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.

Note: If you do not know the class ID of the COM object you wish to expose as an IDL object, you may be able to determine it using an application provided by Microsoft. See Finding COM Class and Program IDs for details.

## 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.

Note: If you do not know the program ID of the COM object you wish to expose as an IDL object, you may be able to determine it using an application provided by Microsoft; see Finding COM Class and Program IDs for details.

## Finding COM Class and Program IDs

In general, if you wish to incorporate a COM object into an IDL program, you will know the COM class or program ID — either because you created the COM object yourself, or because the developer of the object provided you with the information.

If you do not know the class or program ID for the COM object you want to use, you may be able to determine them using the OLE/COM Object Viewer application provided by Microsoft. You can download the OLE/COM Object Viewer at no charge directly from Microsoft. As of this writing, you can locate the tool by pointing your Web browser to the following URL:

http://www.microsoft.com/com

and then selecting Downloads from the Resources menu.

The OLE/COM Object Viewer displays all of the COM objects installed on a computer, and allows you to view information about the objects and their interfaces.

Note: You can copy an object’s class ID to the clipboard by selecting the object in the leftmost panel of the object viewer, clicking the right mouse button, and selecting “Copy CLSID to Clipboard” from the context menu.

If you have an IDL program that instantiates a COM object running on your computer, you can determine either the class ID or the program ID by using the HELP command with the OBJECTS keyword. IDL displays the full dynamic subclass name, including the class ID or program ID that was used when the object was created.