Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function creates a default, or standard, marshaling object in either the client process or the server process, depending on the caller, and returns a pointer to that object's IMarshalimplementation.

Syntax

STDAPI CoGetStandardMarshal(
  REFIID 
riid,
  IUnknown* 
pUnk,
  DWORD 
dwDestContext,
  LPVOID 
pvDestContext,
  DWORD 
mshlflags,
  LPMARSHAL* 
ppMarshal
);

Parameters

riid

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

pUnk

[in] Pointer to the interface to be marshaled.

dwDestContext

[in] Destination context where the specified interface is to be unmarshaled. Values for dwDestContextcome from the enumeration MSHCTX.

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. Valid values come from the MSHLFLAGSenumeration.

ppMarshal

[out] Address of IMarshal* pointer variable that receives the interface pointer to the standard marshaler.

Return Value

This function supports the standard return values E_FAIL, E_OUTOFMEMORY and E_UNEXPECTED, as well as the following:

S_OK

The IMarshalinstance was returned successfully.

CO_E_NOTINITIALIZED

The CoInitializefunction was not called on the current thread before this function was called.

Remarks

The CoGetStandardMarshalfunction creates a default, or standard, marshaling object in either the client process or the server process, as may be necessary, and returns that object's IMarshalpointer to the caller.

If you implement IMarshal, you may want your implementation to call CoGetStandardMarshalas a way of delegating to COM's default implementation any destination contexts that you do not fully understand or want to handle. Otherwise, you can ignore this function, which COM calls as part of its internal marshaling procedures.

When the COM library in the client process receives a marshaled interface pointer, it looks for a CLSID to be used in creating a proxy for the purposes of unmarshaling the packet.

If the packet does not contain a CLSID for the proxy, COM calls CoGetStandardMarshal, passing a NULL pUnkvalue. This function creates a standard proxy in the client process and returns a pointer to that proxy's implementation of IMarshal. COM uses this pointer to call CoUnmarshalInterfaceto retrieve the pointer to the requested interface.

If your OLE server application's implementation of IMarshalcalls CoGetStandardMarshal, you should pass both the IID of ( riid), and a pointer to ( pUnk), the interface being requested.

This function performs the following tasks:

  1. Determines whether pUnkis NULL.

  2. If pUnkis NULL, creates a standard interface proxy in the client process for the specified riidand returns the proxy's IMarshalpointer.

  3. If pUnk is not NULL, checks to see if a marshaler for the object already exists, creates a new one if necessary, and returns the marshaler's IMarshalpointer.

To determine whether the platform supports this function, see Determining Supported COM APIs.

Requirements

Header objbase.h
Library ole32.lib
Windows Embedded CE Windows CE 3.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also

Reference

COM Functions