CoGetMarshalSizeMax  1MXG4CR

Returns an upper bound on the number of bytes needed to marshal the specified interface pointer to the specified object.

STDAPI CoGetMarshalSizeMax(

    ULONG *pulSize,

//Pointer to the upper-bound value

    REFIID riid,

//Reference to the identifier of the interface

    IUnknown * pUnk,

//Pointer to the interface to be marshaled

    DWORD dwDestContext,

//Destination process

    LPVOID pvDestContext,

//Reserved for future use

    DWORD mshlflags

//Reason for marshaling

   );

 

 

Parameters

pulSize

[out] Pointer to the upper-bound value on the size, in bytes, of the data packet to be written to the marshaling stream; a value of zero means that the size of the packet is unknown.

riid

[in] Reference to the identifier of the interface whose pointer is to be marshaled. This interface must be derived from the IUnknown1NEM0LU interface.

pUnk

[in] Pointer to the interface to be marshaled; can be NULL. This interface must be derived from the IUnknown1NEM0LU interface.

dwDestContext

[in] Destination context where the specified interface is to be unmarshaled. Values for dwDestContext come from the enumeration MSHCTX3T9G8X5. Currently, unmarshaling can occur either in another apartment of the current process (MSHCTX_INPROC) or in another process on the same computer as the current process (MSHCTX_LOCAL).

pvDestContext

[in] Reserved for future use; must be NULL.

mshlflags

[in] Flag indicating whether the data to be marshaled is to be transmitted back to the client process the normal case or written to a global table, where it can be retrieved by multiple clients. Values come from the enumeration MSHLFLAGS8DNAZK.

 

Return Values

This function supports the standard return value E_UNEXPECTED, as well as the following:

S_OK

The upper bound was returned successfully.

CO_E_NOTINITIALIZED

The CoInitializeDN8I4F or OleInitialize9.DDFN function was not called on the current thread before this function was called.

 

Remarks

This function performs the following tasks:

  1.  Queries the object for an IMarshal pointer or, if the object does not implement IMarshal, gets a pointer to COM s standard marshaler.

  2.  Using whichever pointer is obtained in the preceding step, calls IMarshal::GetMarshalSizeMax.

  3.  Adds to the value returned by the call to GetMarshalSizeMax the size of the marshaling data header and, possibly, that of the proxy CLSID to obtain the maximum size in bytes of the amount of data to be written to the marshaling stream.

 

You do not explicitly call this function unless you are implementing IMarshal, in which case your marshaling stub should call this function to get the correct size of the data packet to be marshaled.

The value returned by this method is guaranteed to be valid only as long as the internal state of the object being marshaled does not change. Therefore, the actual marshaling should be done immediately after this function returns, or the stub runs the risk that the object, because of some change in state, might require more memory to marshal than it originally indicated.

See Also

CoMarshalInterface, IMarshal::GetMarshalSizeMax