Creates a new object and initializes it from a storage object through an internal call to IPersistFile::Load.
HRESULT CoGetInstanceFromIStorage( COSERVERINFO *pServerInfo, CLSID *pClsid, IUnknown *punkOuter, DWORD dwClsCtx, IStorage *pstg, 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 pstg storage object 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 IStorage::Stat to find the class of the object.
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.
A pointer to the storage object 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.|
CoGetInstanceFromIStorage creates a new object and initializes it from a storage object 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 value or has no associated registry information, this function will instantiate an object on the computer where pstg 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]|