CoSetCallContext

HRESULT CoSetCallContext(punk);

Establishes the call context for the current call, overriding the default call context object normally available via CoGetCallContext.

This function is provided primarily for objects performing custom marshaling. Before transferring control from their stub or IPC mechanism to the server-side code, a custom marshaler may establish the call context via CoSetCallContext so that subsequent objects can be written to take advantage of call-level security or other caller-specific contextual information in a transport neutral fashion; for example, without regard to whether an object between them and the client was remoted via custom marshaling.

The call context reverts automatically at the end of each call. Furthermore, a custom marshaling layer which calls CoSetCallContext prior to entering the server need not call CoSetCallContext(NULL) after each returning call.

A second call to CoSetCallContext with a non-NULL punk will Release the first punk and AddRef the second.

Argument

Type

Description

punk

IUnknown*

When non-NULL, the IUnknown which is to be QueryInterface'd for the requested call context interface by subsequent calls to CoGetCallContext during the span of the current call. This interface is AddRef'd prior to returning. When NULL, resets the call context to the COM-provided default for the current call.

Returns

S_OK

Success.

E_INVALIDARG

One or more arguments are invalid.