Platform SDK: Transaction Server

GetObjectContext Function, IObjectContext::CreateInstance Method Example

[This product will work only on Windows NT 4.0 versions and earlier. For Windows 2000 and later, see COM+ (Component Services).]

#include <mtx.h>


IObjectContext* pObjectContext = NULL;
IAccount* pAccount = NULL;
HRESULT hr;

// Get the object's ObjectContext.
hr = GetObjectContext(&pObjectContext);

// Use it to instantiate another object.
hr = pObjectContext->CreateInstance(CLSID_CAccount,
    IID_IAccount, (void**)&pAccount);