RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
Mtx.GetObjectContext Function

Fetches the IObjectContext interface for the current thread.

Pascal
function GetObjectContext: IObjectContext;
C++
IObjectContext GetObjectContext();

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.
 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!