CreateObjectEx Function | |
Creates an instance of a registered COM object (such as a X# Automation server) on a remote computer.
Namespace:
XSharp.VFP
Assembly:
XSharp.VFP (in XSharp.VFP.dll) Version: 2.19
Syntax FUNCTION CreateObjectEx(
cClsIdOrcProgId,
cComputerName,
cIID
) AS Object CLIPPER
[ClipperCallingConventionAttribute(new string[] { ... })]
public static Object CreateObjectEx(
Usual cClsIdOrcProgId = default,
Usual cComputerName = default,
Usual cIID = default
)
Request Example
View SourceParameters
- cClsIdOrcProgId (Optional)
- Type: Usual
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 (Optional)
- Type: Usual
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 (Optional)
- Type: Usual
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 X# attempts to access the default interface (IID) of cCLSID | cPROGID.
Return Value
Type:
Object
Object
Remarks
CreateObjectEx( ) returns an object reference to the COM object if it is successfully instantiated.
CreateObjectEx( ) cannot be used to instantiate X# classes such as forms – use CreateObject( ) to instantiate X# 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 X# 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 X# 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 X# to create Automation servers, see Sharing Information and Adding OLE.
Examples 1x = CreateObjectEx("excel.application","",;
2"{000208D5-0000-0000-C000-000000000046}")
The following is a valid function call for an excel application object. It will return the excel.application default interface.
1x = CreateObjectEx("excel.application","","")
See Also