Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Provides access to COM object properties, methods, and events through early binding.
GETINTERFACE(oObject [, cIID | cInterface[, cTypelib | cProgID]])
Returns
COM Object Interface reference
Parameters
- oObject
Specifies the target COM object. - cIID
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. - cInterface
Specifies the interface name. - cTypelib
Specifies the name of the type library containing the oObject class. - cProgID
Specifies the name of the program to be used to lookup the type library.
Remarks
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 9x platform (Windows95, Windows98, and Windows Me), 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:
oX = GETINTERFACE(x, "Imyclass", "myclass1.TLB")
You can use the following code for a DLL built on Windows XP, Windows 2000 or Windows NT:
oX = GETINTERFACE(x, "Imyclass", "myclass1.DLL")
Example
The following code snippet is an example of a method you can use in your Visual FoxPro COM server to handle transactions in a COM+ Application. This sample requires that the COM server containing this code be added to a COM+ Application before it can be called by a client.
LOCAL oMTX, oContext, oContextState
LOCAL lTxnState, lGetTxnState, lDone, lGetDone
lGetDone = .F. && initialize setting
lGetTxnState = 0 && initialize setting
oMTX = CREATEOBJECT("MTXAS.APPSERVER.1")
oContext = oMTX.GetObjectContext()
oContextState = GetInterface(oContext,"IContextState")
* Handle activation setting (Doneness)
* Values: .T. - Deactivate, .F. - Leave activated
lDone = .T.
oContextState.SetDeactivateOnReturn(lDone)
oContextState.GetDeactivateOnReturn(@lGetDone)
* Handle transaction setting (Consistency)
* Values: 0 - commit, 1 - abort
lTxnState = 1
oContextState.SetMyTransactionVote(lTxnState)
oContextState.GetMyTransactionVote(@lGetTxnState)
See Also
CREATEOBJECTEX( ) | Early (vtable) and Late (IDispatch) Binding | GETOBJECT( ) | SYS(2333) - ActiveX Dual Interface Support | Viewing Type Library Information