cfobject:COM オブジェクト

COM(Component Object Model)オブジェクトを作成および操作します。また、登録されている自動サーバーオブジェクトタイプを呼び出します。OLEView、COM および DCOM については、Microsoft OLE 開発 Web サイト www.microsoft.com を参照してください。
このタグを使用するには、オブジェクトのプログラム ID またはファイル名、IDispatch インターフェイスから利用できるメソッドとプロパティおよびオブジェクトのメソッドの引数と戻り値のタイプを指定します。ほとんどの COM オブジェクトについて、OLEView ユーティリティを使用してこの情報を得ることができます。

注意:

UNIX 上では、cfobject タグは COM オブジェクトをサポートしません。

シンタックス

<cfobject
class = "program ID"
name = "instance name"
action = "create|connect"
context = "inproc|local|remote"
server = "server name">
type = "com"
<cfobject class = "program ID" name = "instance name" action = "create|connect" context = "inproc|local|remote" server = "server name"> type = "com"
<cfobject 
class = "program ID" 
name = "instance name" 
action = "create|connect" 
context = "inproc|local|remote" 
server = "server name"> 
type = "com"
注意:

このタグの属性は attributeCollection 属性で指定でき、その値は構造体になります。attributeCollection 属性で構造体の名前を指定し、タグの属性名を構造体のキーとして使用します。

NTLM 属性の使用

<cfobject
authType="NTLM"
ntlmdomain="domain name"
workstation="workstation name"
type="webservice"
name="ws"
webservice="WSDL URL"
username = "user name"
password = "password">
<cfobject authType="NTLM" ntlmdomain="domain name" workstation="workstation name" type="webservice" name="ws" webservice="WSDL URL" username = "user name" password = "password">
<cfobject
authType="NTLM"
ntlmdomain="domain name"
workstation="workstation name"
type="webservice" 
name="ws"
webservice="WSDL URL" 
username = "user name"
password = "password">

ここで、

authType

使用する認証タイプ。NTLM または BASIC を使用できます。

ntlmdomain

ドメインコントローラーのホスト名。

workstation

クライアントマシンのホスト名。

注意:

authType=NTLM の場合、ntlmDomain は必須です。

ユーザーがドメインに属している場合は、ntlmDomain 属性が必須です。ユーザーがドメインに属していない場合、ntlmDomain 属性はオプションです。

関連項目

ReleaseComObjectcfcollectioncfexecute、『ColdFusion アプリケーションの開発』の「COM」

属性

属性

必須/オプション

デフォルト

説明

class

必須

 

呼び出すオブジェクトのコンポーネントプログラム ID です。Java スタブを使用して COM オブジェクトに接続するときは、class に COM オブジェクトのプログラム ID を指定する必要があります。

name

必須

 

文字列です。インスタンス化されたコンポーネント名を指定します。

action

オプション

create

  • create:メソッドまたはプロパティを呼び出す前に COM オブジェクト(通常は DLL)のインスタンスを作成します。
  • connect:サーバー上で実行されている COM オブジェクト(通常は EXE)に接続します。

context

オプション

 

  • inproc
  • local
  • remote
    Windows では、この属性を指定しない場合、レジストリーの設定が使用されます。

server

context = "Remote" の場合は必須

 

サーバー名です。Universal Naming Convention(UNC)または Domain Name Service(DNS)の表記規則を使用して、次のいずれかの形式で指定します。


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

type

オプション

 

オブジェクトのタイプです。com は COM オブジェクトを意味します。

<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 by 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>
<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 by 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>
<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 by 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>

ヘルプをすばやく簡単に入手

新規ユーザーの場合