CoGetObjectContext function (combaseapi.h)

Returns the context for the current object.

Syntax

HRESULT CoGetObjectContext(
  [in]  REFIID riid,
  [out] LPVOID *ppv
);

Parameters

[in] riid

A reference to the ID of an interface that is implemented on the context object.

For objects running within COM applications, IID_IComThreadingInfo, IID_IContext, and IID_IContextCallback are available.

For objects running within COM+ applications, IID_IObjectContext, IID_IObjectContextActivity IID_IObjectContextInfo, and IID_IContextState are available.

[out] ppv

The address of a pointer to the interface specified by riid on the context object.

Return value

This function can return the standard return values E_OUTOFMEMORY and E_UNEXPECTED, as well as the following values.

Return code Description
S_OK
The object context was successfully retrieved.
E_NOINTERFACE
The requested interface was not available.
CO_E_NOTINITIALIZED
Before this function can be called, the CoInitializeEx function must be called on the current thread.

Remarks

CoGetObjectContext retrieves the context for the object from which it is called, and returns a pointer to an interface that can be used to manipulate context properties. Context properties are used to provide services to configured components running within COM+ applications.

For components running within COM applications, the following interfaces are supported for accessing context properties: IComThreadingInfo, IContext, and IContextCallback.

For components running within COM+ applications, the following interfaces are supported for accessing context properties: IObjectContext, IObjectContextActivity, IObjectContextInfo, and IContextState.

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

See also

Contexts and Threading Models