CoGetMarshalSizeMax function (combaseapi.h)
Returns an upper bound on the number of bytes needed to marshal the specified interface pointer to the specified object.
Syntax
HRESULT CoGetMarshalSizeMax(
[out] ULONG *pulSize,
[in] REFIID riid,
[in] LPUNKNOWN pUnk,
[in] DWORD dwDestContext,
[in, optional] LPVOID pvDestContext,
[in] DWORD mshlflags
);
Parameters
[out] pulSize
A pointer to the upper-bound value on the size, in bytes, of the data packet to be written to the marshaling stream. If this parameter is 0, the size of the packet is unknown.
[in] riid
A reference to the identifier of the interface whose pointer is to be marshaled. This interface must be derived from the IUnknown interface.
[in] pUnk
A pointer to the interface to be marshaled. This interface must be derived from the IUnknown interface.
[in] dwDestContext
The destination context where the specified interface is to be unmarshaled. Values for dwDestContext come from the enumeration MSHCTX.
[in, optional] pvDestContext
This parameter is reserved and must be NULL.
[in] mshlflags
Indicates 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 MSHLFLAGS.
Return value
This function can return the standard return value E_UNEXPECTED, as well as the following values.
Return code | Description |
---|---|
|
The upper bound was returned successfully. |
|
Before this function can be called, either the CoInitialize or OleInitialize function must be called. |
Remarks
This function performs the following tasks:
- Queries the object for an IMarshal pointer or, if the object does not implement IMarshal, gets a pointer to COM's standard marshaler.
- Using the pointer obtained in the preceding item, calls IMarshal::GetMarshalSizeMax.
- 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.
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.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps | UWP apps] |
Minimum supported server | Windows 2000 Server [desktop apps | UWP apps] |
Target Platform | Windows |
Header | combaseapi.h (include Objbase.h) |
Library | Ole32.lib |
DLL | Ole32.dll |