Winapi.Mtx.GetObjectContext

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function GetObjectContext: IObjectContext;

Properties

Type Visibility Source Unit Parent
function public Winapi.Mtx.pas Winapi.Mtx Winapi.Mtx

Description

Fetches the IObjectContext interface for the current thread.

When a COM object is created as part of the MTS environment or of a COM+ package (that is, a transactional object), a corresponding context object is also created. This context object exists for the entire lifetime of its transactional object, across one or more reactivation cycles. The object context keeps track of the object during deactivation. Call GetObjectContext to obtain an IObjectContext interface pointer for the context object associated with the current thread.

Pass a pointer that receives the IObjectContext interface pointer as ppInstanceContext.

GetObjectContext returns S_OK if it returns a pointer to the context object. Otherwise, it returns an error code.

Note: C++Builder automatically fetches the IObjectContext interface when a transactional object is activated. The interface pointer is stored as the m_spObjectContext member of the transactional object's class.

Warning: When writing a transactional object that uses VCL classes, use the Get_ObjectContext method of TMtsDll instead. ComSvcs.h defines GetObjectContext using a macro so that it calls COM+ or MTS, depending on the system you use to build the transactional object. This macro interferes with the GetObjectContext method of some VCL classes, and so it is undefined when you include the VCL headers.

See Also