Bridges > COM Import Bridge and ActiveX > COM Import Bridge > About Using COM Objects In IDL

# About Using COM Objects In IDL

If you want to incorporate a COM object that does not present its own user interface into your IDL application, use IDL’s IDLcomIDispatch object class.

IDL’s IDLcomIDispatch object class creates an IDL object that uses the COM IDispatch interface to communicate with an underlying COM object. When you create an IDLcomIDispatch object, you provide information about the COM object you wish to use, and IDL handles instantiation of and communication with the object. You can call the COM object’s methods and get and set its properties using standard IDL object conventions and syntax.

Note: If the COM object you want to use in your IDL application is an ActiveX control, use the WIDGET_ACTIVEX routine, discussed in Using ActiveX Controls in IDL.

## Array Data Storage Format

COM, like C, stores array data in row-major format. IDL stores array data in column- major format. See Multidimensional Array Storage and Access for a detailed discussion of this issue and its implications for IDL application design.

## Object Creation

To create an IDL object that encapsulates a COM object, use the OBJ_NEW function as described in Creating IDLcomIDispatch Objects. IDL creates a dynamic subclass of the IDLcomIDispatch object class, based on information you specify for the COM object.

## Method Calls and Property Management

Once you have created your IDLcomIDispatch object within IDL, use normal IDL object method calls to interact with the object. (See Chapter 1, “The Basics of Using Objects in IDL” (Object Programming) for a discussion of IDL objects.) COM object properties can be set and retrieved using the GetProperty and SetProperty methods implemented for the IDLcomIDispatch class. See Method Calls on IDLcomIDispatch Objects and Managing COM Object Properties for details.

## Object Destruction

Destroy IDLcomIDispatch objects using the OBJ_DESTROY procedure. See Destroying IDLcomIDispatch Objects for details.

## Registering COM Components on a Windows Machine

Before a COM object or ActiveX control can be used by a client program, it must be registered on the Windows machine. In most cases, components are registered by the program that installs them on the machine. If you are using a component that is not installed by an installation program that handles the registration, you can register the component manually.

To register a component (.dll or .exe) or a control (.ocx), use the Windows command line program regsvr32, supplying it with name of the component or control to register. For example, the IDL distribution includes a COM component named RSIDemoComponent, contained in a file named RSIDemoComponent.dll located in the examples\doc\bridges\COM subdirectory of the IDL distribution. To register this component, do the following:

1. Open a Windows command prompt.
2. Change directories to the examples\doc\bridges\COM subdirectory of the IDL distribution.
3. Enter the following command:

regsvr32 RSIDemoComponent.dll

Windows will display a pop-up dialog informing you that the component has been registered. (You can specify the “ /s “ parameter to regsvr32 to prevent the dialog from being displayed.)

Note: You only need to register a component once on a given machine. It is not necessary to register a component before each use.