Export (0) Print
Expand All

IObjectContextActivity Interface

Archived content. No warranty is made as to technical accuracy. Content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

The IObjectContextActivity interface is used to retrieve a unique identifier associated with the current activity. This activity identifier is a GUID, and is only valid for the lifetime of the current activity.

On This Page

Remarks
IObjectContextActivity::GetActivityId Method

Remarks

The header file for the IObjectContextActivity is mtx.h. You must also link mtxguid.lib to your project to use this interface.

You obtain a reference to an object's IObjectContextActivity interface by calling QueryInterface on the object's ObjectContext. For example:

m_pIObjectContext->QueryInterface
    (IID_IObjectContextActivity, 
    (void**)&m_pIObjectContextActivity));

The IObjectContextActivity interface provides the following methods.

Method

Description

 

 

Getactivityid

Retrieves the GUID associated with the current activity.

IObjectContextActivity::GetActivityId Method

Retrieves the GUID associated with the current activity.

Provided By

IObjectContextActivity HRESULT IObjectContextActivity::GetActivityId(

GUID * pActivityId);

Parameters

pActivityId

[out] A reference to the GUID associated with the current activity.

Return Values

S_OK

The GUID of the current activity is returned in the parameter pActivityId.

E_INVALIDARG

The argument passed in the pActivityId parameter is a NULL pointer.

E_UNEXPECTED

An unexpected error occurred.

Example

GetActivityId Method Example

#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();
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft