#include <mtx.h>
HRESULT hr = S_OK;
IObjectContext *pIObjectContext = NULL;
IObjectContextActivity *pIObjectContextActivity = NULL;
GUID activityId;
// Get object context
hr = GetObjectContext(&pIObjectContext);
// Get IObjectContextActivity interface
hr = pIObjectContext->
QueryInterface(IID_IObjectContextActivity,
(void**)&pIObjectContextActivity);
// Use IObjectContextActivity to retrieve
// the activity GUID.
hr = pIObjectContextActivity->
GetActivityId(&activityId);
// Do something with the activity GUID here.
// Release the IObjectContextActivity
// and the IObjectContext pointers
pIObjectContextActivity->Release();
pIObjectContext->Release();