cfobject type = "com"

Description

Lets you create and use Component Object Model (COM) objects. With this tag, you can invoke any automation server object type registered on a computer. You can use a utility like Microsoft's OLEView to browse COM objects.

OLEView, and information about COM and DCOM, can be found at Microsoft's OLE Development web site http://www.microsoft.com/oledev/.

To use cfobject, you must provide the object's program ID or filename, the methods and properties available through the IDispatch interface, and the arguments and return types of the object's methods. The OLEView utility can give you this information for most COM objects.

Category

Extensibility tags

Syntax

<cfobject type = "COM"
  action = "action"
  class = "program_ID"
  name = "text"
  context = "context"
  server = "server_name"> 

See also

cfcollection, cfexecute, cfgraph, cfindex, cfreport, cfsearch, cfservlet, cfwddx

Attributes

Attribute
Description
action
Required. One of the following:
  • Create    Instantiates a COM object (typically a DLL) before invoking methods or properties.
  • Connect    Connects to a COM object (typically an EXE) running on the server specified in server.
class
Required. The component ProgID for the object to invoke.
name
Required. Name for the object.
context
Optional. InProc, Local, or Remote. If not specified, uses Registry setting.
server
Required when context = "Remote". Valid server name using UNC (Universal Naming Convention) or DNS (Domain Name Server) conventions, in one of the following forms:
server = "\\lanserver" 
server = "lanserver" 
server = "http://www.servername.com" 
server = "www.servername.com" 
server = "127.0.0.1" 

Example

<html>
<head>
<title>cfobject (COM) Example</title>
</head>

<body>
<H3>cfobject (COM) Example</H3>
<!---
Create a COM object as an inproc server (DLL).
(class = prog-id)
--->
<cfobject action = "Create"
  type = "COM"
  class = Allaire.DocEx1.1
  name = "obj"> 

<!---
Call a method.
Note that methods that expect no arguments should 
be called using empty parenthesis.
--->
<cfset obj.Init()>

<!---
This object is a collection object, and should 
support at a minimum:
Property : Count
Method : Item(inarg, outarg)
and a special property called _NewEnum 
--->
<cfoutput>
 This object has #obj.Count# items.
 <BR>
 <HR>
</cfoutput>

<!---
Get the 3rd object in the collection.
--->
<cfset emp = obj.Item(3)>
<cfoutput>
 The last name in the third item is #emp.lastname#.
 <BR>
 <HR>
</cfoutput>

<!---Loop over all the objects in the collection.--->
<P>Looping through all items in the collection:
<BR>
<cfloop collection = #obj# item = file2>
 <cfoutput>
  Last name: #file2.lastname# <BR>
 </cfoutput>
</cfloop>
...
</body>
</html>