# Getting Started with COM/DCOM

ColdFusion is an automation (late-binding) COM client. This implies that the COM object has to support the IDispacth interface, and that arguments for methods and properties be standard automation types. Since ColdFusion is a typeless language, it uses the object's type information to correctly set up the arguments on call invocations. Any ambiguity in the object's data-types could lead to unexpected behavior.

It is important to use server-side COM objects in ColdFusion, that is, they should not have a graphical user interface. If you invoke an object with a graphical interface in your ColdFusion application, a window for the component might appear on the Web server desktop, not on the user's desktop. This could tie up ColdFusion server threads and result in further Web server requests not 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.

## Requirements for COM

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

- The Microsoft OLE/COM Object Viewer, available from Microsoft. It is a handy tool for viewing registered COM objects.
- The COM objects you want to use in your ColdFusion application pages. These are typically DLL or EXE files. These components should allow late binding, that is, they implement the IDispatch interface. Object Viewer allows you to view the object's class information so that you can properly define the CLASS attribute for the CFOBJECT tag. It also displays the object's supported interfaces, which allows you to discover the properties and methods (for the IDispatch interface) of the object.

## Registering the object

Once you've acquired the object you want to use, you may need to register it with Windows in order for ColdFusion (or anything else) to find it. Some objects may be deployed with their own setup programs that register objects automatically, while others may require manual registration.

Inproc object servers (*.dll, *.ocx) can be registered manually by using the "regsvr32.exe" utility using the following form:

    regsvr32 c:\path\servername.dll

Local servers (*.exe) are typically registered either by simply starting them or specifying a command line parameters like:

    C:\pathname\servername.exe -register

## Finding the component ProgID and methods

Your COM object should provide documentation explaining each of the component's methods and the ProgID. With this information, you're ready to work with the CFOBJECT tag. If you don't have documentation, use the Object Viewer to view the component's interface.

### 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's Program ID as well as its methods and properties.

Once you've installed a COM object, make sure you register it using the regsvr32.exe utility. Otherwise you won't find the object in the Object Viewer. 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 Program ID of the COM object you want to use. The Object Viewer also gives you access to options for the operation of the object.

| To view an object's properties:

1. Open the Object Viewer and scroll to the object you want to examine.
2. Select and expand the object in the Object Viewer.
3. Right-click the object to view it. If you view the TypeInfo, you'll see the object's methods and properties. Some objects will not have any access to the TypeInfo area. This is determined when an object is built and by the language used.