Getting started with COM and DCOM



ColdFusion is an automation (late-binding) COM client. As a result, the COM object must support the IDispatch interface, and arguments for methods and properties must be standard automation types. Because ColdFusion is a typeless language, it uses the object type information to correctly set up the arguments on call invocations. Any ambiguity in the object data types can lead to unexpected behavior.

In ColdFusion, only use server-side COM objects, which do not have a graphical user interface. If your ColdFusion application invokes an object with a graphical interface in a window, the component could appear on the web server desktop, not on the client desktop. This behavior can take up ColdFusion server threads and prevent further web server requests from being serviced.

ColdFusion can call Inproc, Local, or Remote COM objects. The attributes specified in the cfobject tag determine which type of object is called.

COM requirements

To use COM components in your ColdFusion application, you need at least the following items:

  • The COM objects (typically DLL or EXE files) that you want to use in your ColdFusion application pages. Ensure that these components implement the IDispatch interface, and therefore allow late binding.

  • Microsoft OLE/COM Object Viewer, available from Microsoft. This tool lets you view registered COM objects.

    Object Viewer lets you view the class information of an object so that you can properly define the class attribute for the cfobject tag. It also displays the interfaces the object supports, so you can discover the properties and methods (for the IDispatch interface) of the object.

Registering the object

After you acquire an object, register it with Windows for ColdFusion (or any other program) to find it. Some objects have setup programs that register objects automatically, while others require manual registration.

You can register Inproc object servers (.dll or .ocx files) manually by running the regsvr32.exe utility using the following form:

regsvr32 c:\path\servername.dll

You typically register Local servers (.exe files) either by starting them or by specifying a command-line parameter, such as the following:

C:\pathname\servername.exe -register

Finding the component ProgID and methods

Your COM object supplier provides documentation that explains each of the component methods and the ProgID. If you do not have documentation, use either the ColdFusion cfdump tag or the OLE/COM Object Viewer to view the component interface.

Using the cfdump tag to view COM object interfaces

Effective with ColdFusion, the ColdFusion cfdump tag displays the following information about a COM object:

  • Public methods

  • Put properties

  • Get properties

The method and property information include the parameter or property types and whether they are in, out, optional, or retval values. The cfdump tag output does not include the ProgID of the object.

Note: The dump header indicates the ColdFusion object class, which is coldfusion.runtime.com.ComProxy, and the COM object CLSID.

Using the OLE/COM Object Viewer

The OLE/COM Object Viewer installation installs the executable, by default, as \mstools\bin\oleview.exe. You use the Object Viewer to retrieve a COM object ProgID, as well as its methods and properties.

To find an object in the Object Viewer, it must be registered, as described in Registering the object. The Object Viewer retrieves all COM objects and controls from the Registry, and presents the information in a simple format, sorted into groups for easy viewing.

By selecting the category and then the component, you can see the ProgID of a COM object. The Object Viewer also provides access to options for the operation of the object.

To view object properties:

  1. Open the Object Viewer and scroll to the object that you want to examine.

  2. Select and expand the object in the left pane of the Object Viewer.

  3. Right-click the object to view it, including the TypeInfo.

    If you view the TypeInfo, you see the object methods and properties. Some objects do not have access to the TypeInfo area, which is determined when an object is built and by the language used.