CoSwitchCallContext

[This is preliminary documentation and subject to change.]

Switches the call context object used by CoGetCallContext.

HRESULT CoSwitchCallContext(
  IUnknown *pNewObject,    //Pointer to an interface on the new call context
  IUnknown **ppOldObject   //Address of output variable that receives a 
                           // pointer to the old call context object
);
 

Parameters

pNewObject
[in] A pointer to an interface on the new call context object. COM will keep a reference to the pointer until CoSwitchCallContext is called with another object. It may be NULL if you are calling CoSwitchCallContext to switch back to the original call context and there was no original call context.
ppOldObject
[out] Address of pointer variable that receives a pointer to the call context object of the call currently in progress. This value is returned so that the original call context can be restored by the custom marshaller. The returned pointer will be NULL if there was no call in progress.

Return Values

S_OK
Success.
E_OUT_OF_MEMORY

Remarks

Custom marshallers call CoSwitchCallContext to change the call context object used by CoGetCallContext. Before dispatching an arriving call, custom marshallers call CoSwitchCallContext, specifying the new context object. After sending a reply, they must restore the original call context by calling CoSwitchCallContext again, this time passing a pointer to the original context object.

Call context objects provided by custom marshallers should support IServerSecurity.

QuickInfo

  Windows NT: Use version 4.0 or later.
  Windows: Use Windows 95 or later. Available as a redistributable for Windows 95.
  Windows CE: Unsupported.
  Header: Declared in objbase.h.
  Import Library: Included as a resource in ole32.dll.

See Also

IServerSecurity, Security in COM, CoGetCallContext