CREATEOBJECTEX( ) Function
Creates an instance of a registered COM object (such as a Visual FoxPro Automation server) on a remote computer.
CREATEOBJECTEX(cCLSID | cPROGID, cComputerName [, cIID])
Return Values
Object
Parameters
cCLSID | cPROGID
Specifies the CLSID (Class Identifier) or PROGID (Programmatic Identifier) for the COM object to instantiate. If you include a CLSID, the COM object must be registered on the remote server you specify with cComputerName. If you include a PROGID, the COM object must be registered on both the your local computer and the remote computer you specify with cComputerName. Attempting to use a PROGID without first registering the server on your local computer will generate the OLE error Code 0x800401f3, "Invalid Class String."For Visual FoxPro automation servers created on your local machine, you can use the server object CLSID and PROGID properties to determine the local CLSID and PROGID values.
cComputerName
Specifies the remote computer on which the COM object is instantiated.If cComputerName is the empty string, the COM object is instantiated on the local computer or a redirected machine as specified in the registry.
cComputerName supports Universal Naming Convention (UNC) names such as "\\myserver" and "myserver," and Domain System Names (DNS) names.
cIID
Specifies the Interface ID GUID of cCLSID | cPROGID when you create an early bound instance of the class. If you pass an empty string as cIID Visual FoxPro attempts to access the default interface (IID) of cCLSID | cPROGID.
Example
x = CREATEOBJECTEX("excel.application","",;
"{000208D5-0000-0000-C000-000000000046}")
Note The following is a valid function call for an excel application object. It will return the excel.application default interface.
x = CREATEOBJECTEX("excel.application","","")
Remarks
CREATEOBJECTEX( ) returns an object reference to the COM object if it is successfully instantiated. CREATEOBJECTEX( ) cannot be used to instantiate Visual FoxPro classes such as forms – use CREATEOBJECT( ) to instantiate Visual FoxPro classes. Note that you can only abbreviate CREATEOBJECTEX( ) to a minimum of 13 characters, distinguishing it from the CREATEOBJECT( ) function.
When you call certain COM classes with CREATEOBJECT( ) they return "No such interface supported" because they do not support an IDispatch interface. Using the cIID parameter you can now access these classes in your applications.
If you pass an empty string ("") as cIID Visual FoxPro attempts to to get the default interface (IID) of the specified CLSID or PROGID.
Because it supports early binding through cIID, CREATEOBJECTEX( ) can help improve performance by avoiding much of the overhead of IDispatch calls.
CREATEOBJECTEX( ) supports creation of new early-bound objects. However, it is also possible that your Visual FoxPro component is passed an object that you want to call via early-binding. You can use the GETINTERFACE( ) support on existing COM objects.
For additional information about using Visual FoxPro to create Automation servers, see Adding OLE .
See Also
CLSID Property | CREATEOBJECT( ) Function | ProgID Property | Server Object | GETINTERFACE( ) Function