IMarshal::MarshalInterface

Marshals an interface pointer into the stream, that is, writes the appropriate data into the stream so that your IMarshal::UnmarshalInterface method can use that data to initialize a proxy object in another process.

HRESULT IMarshal::MarshalInterface(

IStream *pStm,
//Stream used for marshaling
REFIID riid,
//Identifies interface being marshaled
void *pv,
//Points to interface pointer being marshaled
DWORD dwDestContext,
//Identifies destination process
void *pvDestContext,
//Reserved for future use
DWORD mshlflags
//Specifies reason for marshaling
);

Parameters

pStm

[in]Points to the stream to be used during marshaling.

riid

[in]Specifies the IID of the interface pointer to be marshaled.

pv

[in]Points to the interface pointer to be marshaled; can be NULL.

dwDestContext

[in] Specifies the destination context, that is, the process in which the unmarshaling will be done. Different marshaling can be done depending on whether the unmarshaling will happen on the local workstation or on a workstation on the network; it's possible for an object to do custom marshaling in one case but not another. The legal values for dwDestContext are taken from the enumeration MSHCTX. For information on the MSHCTX enumeration, see the "Data Structures" section.

pvDestContext

[in] Reserved for use with future MSHCTX values.

mshlflags

[in]Specifies why marshaling is taking place. The legal values for mshlflags are taken from the MSHLFLAGS enumeration. For information on the MSHLFLAGS enumeration, see the "Data Structures" section.

Return Values

S_OK

The interface pointer was marshaled successfully.

E_FAIL

Indicates that the implementation failed.

E_NOINTERFACE

The specified interface was not supported.

STG_E_MEDIUMFULL

The stream was full.

Comments

This method is called from the originating side (that is, the side doing the marshaling). This method sends information to the receiving side by writing that information into the stream; on the receiving side, the information will be read from the stream and used to initialize a proxy object.

Notes to Implementors

Your implementation of IMarshal::MarshalInterface must write to the stream whatever data is needed to initialize the proxy on the receiving side. Your implementation can delegate some destination contexts to the standard marshaling implementation, which is available by calling the CoGetStandardMarshal API function. You should always delegate if the dwDestContext parameter contains a value that your implementation does not understand; this allows new destination contexts to be defined in the future.

Your implementation cannot assume the stream is large enough to hold all the data; it must still take into account the possibility that the stream may return STG_E_MEDIUMFULL errors. Just before exiting, your implementation should position the seek pointer in the stream immediately after the last byte of data written.

Note that the data marshaled by IMarshal::MarshalInterface can be unmarshaled zero or more times; this may happen if the marshaled data is stored in a global table, from which it may be unmarshaled many times by different client processes. Marshalers must be able to handle the result of multiple unmarshalings. For example, suppose the unmarshaling process creates a proxy that forwards calls to a stub interface in the server application; this stub interface must be able to deal with zero or more proxies being created from the same initialization data.

If the pv parameter is NULL and your implementation needs that interface pointer, it can call IUnknown::QueryInterface on the current object to get it. The pv parameter exists merely to improve efficiency.

See Also

CoGetStandardMarshal, IMarshal::GetMarshalSizeMax, IMarshal::GetUnmarshalClass, IMarshal::UnmarshalInterface

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