Creates a new object and initializes it from a file using IPersistFile::Load.
HRESULT CoGetInstanceFromFile( COSERVERINFO *pServerInfo, CLSID *pClsid, IUnknown *punkOuter, DWORD dwClsCtx, DWORD grfMode, OLECHAR *pwszName, DWORD dwCount, MULTI_QI *pResults );
A pointer to a COSERVERINFO structure that specifies the computer on which to instantiate the object and the authentication setting to be used. This parameter can be NULL, in which case the object is instantiated on the current computer, at the computer specified under the RemoteServerName registry value for the class, or at the computer where the pwszName file resides if the ActivateAtStorage value is specified for the class or there is no local registry information.
A pointer to the class identifier of the object to be created. This parameter can be NULL, in which case there is a call to GetClassFile, using pwszName as its parameter to get the class of the object to be instantiated.
When non-NULL, indicates the instance is being created as part of an aggregate, and punkOuter is to be used as the pointer to the new instance's controlling IUnknown. Aggregation is not supported cross-process or cross-computer. When instantiating an object out of process, CLASS_E_NOAGGREGATION will be returned if punkOuter is non-NULL.
Values from the CLSCTX enumeration.
Specifies how the file is to be opened. See STGM Constants.
The file used to initialize the object with IPersistFile::Load. This parameter cannot be NULL.
The number of structures in pResults. This parameter must be greater than 0.
An array of MULTI_QI structures. Each structure has three members: the identifier for a requested interface (pIID), the location to return the interface pointer (pItf) and the return value of the call to QueryInterface (hr).
This function can return the standard return value E_INVALIDARG, as well as the following values.
||The function retrieved all of the interfaces successfully.|
||At least one, but not all of the interfaces requested in the pResults array were successfully retrieved. The hr member of each of the MULTI_QI structures indicates with S_OK or E_NOINTERFACE whether the specific interface was returned.|
||None of the interfaces requested in the pResults array were successfully retrieved.|
CoGetInstanceFromFile creates a new object and initializes it from a file using IPersistFile::Load. The result of this function is similar to creating an instance with a call to CoCreateInstanceEx, followed by an initializing call to IPersistFile::Load, with the following important distinctions:
- Fewer network round trips are required by this function when instantiating an object on a remote computer.
- In the case where dwClsCtx is set to CLSCTX_REMOTE_SERVER and pServerInfo is NULL, if the class is registered with the ActivateAtStorage sub-key or has no associated registry information, this function will instantiate an object on the computer where pwszName resides, providing the least possible network traffic.
|Minimum supported client||Windows 2000 Professional [desktop apps only]|
|Minimum supported server||Windows 2000 Server [desktop apps only]|