Initializes a proxy object using data written into the stream by a previous call to the CoMarshalInterface function, and returns an interface pointer to that proxy object.

STDAPI CoUnmarshalInterface(

IStream * pStm,
//Stream used for unmarshalling
REFIID riid,
//IID of interface pointer desired
void ** ppv
//Receives the interface pointer



Points to the stream from which the interface pointer is to be unmarshalled.


Specifies the IID of the interface pointer desired.


Receives the interface pointer.

Return Values


Indicates the interface was unmarshalled successfully.


Indicates pStm is an invalid pointer.


Indicates the CoInitialize or OleInitialize function was not called on the current thread before this function was called.


Indicates the object application has been disconnected from the remoting system (for example, as a result of a call to the CoDisconnectObject function).


Indicates an error occurred reading the registration database.


Out of memory.


Indicates one or more arguments are invalid.


Indicates an unexpected error occurred.


Indicates the final QueryInterface of this function for the requested interface returned E_NOINTERFACE.


Indicates an unspecified error.

CoCreateInstance errors

Indicates an error occurred when creating the handler (standard or custom marshaling).


The main steps that CoUnmarshalInterface performs are the following:

  1. The function reads a CLSID from the stream.

  2. If standard marshalling is being used, the function gets an IMarshal pointer to an instance of the standard unmarshaller. If custom marshalling is being used, the function creates a proxy by calling the CoCreateInstance function, passing the CLSID it read from the stream, and requests an IMarshal interface pointer to the newly created proxy.

  3. Using whichever IMarshal interface pointer it has acquired, the function then calls IMarshal::UnmarshalInterface and, if appropriate, IMarshal::ReleaseMarshalData.

You typically do not need to call this function. The primary caller of this function is OLE, from within interface proxies or stubs that unmarshal an interface pointer.

The only place where you might need to call this function is from your implementation of IMarshal::UnmarshalInterface, if you are performing custom marshaling. If your implementation of IMarshal::MarshalInterface called the CoMarshalInterface function to marshal an interface pointer to the stream, you must call CoUnmarshalInterface to retrieve that interface pointer. The retrieved interface pointer is typically a pointer to a private object in the originating process.

See Also

CoMarshalInterface, IMarshal::UnmarshalInterface

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database