cfobject: COM object

Description

Creates and manipulates a Component Object Model (COM) object. Invokes a registered automation server object type.

For information on OLEView, and about COM and DCOM, see the Microsoft OLE Development website: www.microsoft.com.

To use this tag, 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. For most COM objects, you can get this information with the OLEView utility.

Note: On UNIX, this tag does not support COM objects.

Syntax

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

See also

ReleaseComObject, cfcollection, cfexecute; COM in Developing Globalized Applications in ColdFusion MX Developer's Guide

Attributes

Attribute Req/Opt Default Description

type

Optional

 

Object type:

  • com
  • corba
  • java

(The other object types do not take the type attribute.)

action

Required

 

  • create: instantiates a COM object (typically, a DLL) before invoking methods or properties.
  • connect: connects to a COM object (typically, an EXE) running on server.

class

Required

 

Component ProgID for the object to invoke. When using Java stubs to connect to the COM object, the class must be the ProgID of the COM object.

name

Required

 

String; name for the instantiated component.

context

Optional

 

  • inproc
  • local
  • remote

On Windows: If not specified, uses Registry setting.

server

Required if context = "Remote"

 

Server name, using Universal Naming Convention (UNC) or Domain Name Serve (DNS) convention, in one of these forms:

  • \\lanserver
  • lanserver
  • http://www.servername.com
  • www.servername.com
  • 127.0.0.1

Example

<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. Methods that expect no arguments should be called 
using empty parentheses. ---> <cfset obj.Init()> <!--- This is a collection object. It 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>

View comments in LiveDocs