JavaScript Editor js editor     Web development 

Main Page

Provides access to COM object properties, methods, and events through early binding.

GETINTERFACE(oObject [, cIID | cInterface[, cTypelib | cProgID]])



Specifies the target COM object.

Specifies the GUID of the target interface of oObject. cIID can be an interface such as "IContextState" or it can be a GUID, such as "{94631BEC-EE81-479A-AE64-A6CFC37B4799}". If it's "IDispatch", then GetInterface() returns an IDispatch (late-bound) reference to the object. If cIID is not specified, then GetInterface() will return the early binding interface for the object.

Specifies the interface name.

Specifies the name of the type library containing the oObject class.

Specifies the name of the program to be used to lookup the type library.


COM Object Interface reference


GetInterface(В ) applies only to COM objects. If you use native Visual FoxPro objects, GetInterface(В ) generates an error. GetInterface(В ) returns an early-bound Object reference.

When a DLL is built on a WindowsВ 95, WindowsВ 98, or Windows Me platform, Visual FoxPro does not include the type library inside the DLL. When you use GETINTERFACE(В ) and refer to a DLL built on one of these platforms, you must use the Type Library name instead of the DLL name as in the following code:

В Copy Code
oX = GETINTERFACE(x, "Imyclass", "myclass1.TLB")

You can use the following code for a DLL built on Windows XP, Windows 2000, or WindowsВ NT:

В Copy Code
oX = GETINTERFACE(x, "Imyclass", "myclass1.DLL")


The following code example provides a method you can use in your Visual FoxPro COM server to handle transactions in a COM+ application. This sample requires that you add the COM server containing this code to a COM+ application before a client calls it.

В Copy Code
LOCAL oMTX, oContext, oContextState
LOCAL lTxnState, lGetTxnState, lDone, lGetDone
lGetDone = .F.     && initialize setting
lGetTxnState = 0  && initialize setting

oContext = oMTX.GetObjectContext()
oContextState = GetInterface(oContext,"IContextState")

* Handle activation setting (Doneness)
* Values: .T. - Deactivate, .F. - Leave activated
lDone = .T.
* Handle transaction setting (Consistency)
* Values: 0 - commit, 1 - abort
lTxnState = 1

See Also

JavaScript Editor js editor     Web development