GetObjectContext function

Retrieves a reference to the context that is associated with the current COM+ object.

For similar functionality, see IMTxAS::GetObjectContext.

Syntax


HRESULT __cdecl GetObjectContext(
  _Out_ IObjectContext **ppInstanceContext
);

Parameters

ppInstanceContext [out]

A reference to IObjectContext on the object's context. If the object's component has not been imported into an MTS package or if the GetObjectContext function is called from a constructor or an IUnknown method, this parameter is set to a NULL pointer.

Return value

This method can return the following values.

Return codeDescription
S_OK

The method completed successfully.

E_INVALIDARG

The argument is invalid.

E_UNEXPECTED

An unexpected error has occurred.

CONTEXT_E_NOCONTEXT

The current object does not have a context associated with it, because either the component was not imported into an application or the object was not created with one of the COM+ CreateInstance methods. This error is also returned if GetObjectContext is called from the constructor or from an IUnknown method.

 

Remarks

An object's context is not accessible from an object's constructor or from any IUnknown method.

An object should never attempt to pass its IObjectContext reference to another object. If you pass an IObjectContext reference to another object, it is no longer a valid reference.

When an object obtains a reference to its IObjectContext, it must release the IObjectContext object when it is finished with it.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

ComSvcs.h

Library

ComSvcs.lib

DLL

ComSvcs.dll

See also

COM+ Contexts and Threading Models
IMTxAS::GetObjectContext
IObjectContext

 

 

Community Additions

ADD
Show: