ISharedPropertyGroup::get_PropertyByPosition Method Example

#include <mtx.h>
#include <mtxspm.h>


IObjectContext* pObjectContext = NULL;
ISharedPropertyGroupManager* pPropGpMgr = NULL;
ISharedPropertyGroup* pPropGp = NULL;
ISharedProperty* pPropNextNum = NULL;
BSTR stName;
VARIANT vNext;
LONG lNextValue = 0L;
HRESULT hr = S_OK;

hr = GetObjectContext(&pObjectContext);

// Get the SharedPropertyGroupManager,
// SharedPropertyGroup, and SharedProperty.
hr = pObjectContext->CreateInstance
	(CLSID_SharedPropertyGroupManager,
	IID_ISharedPropertyGroupManager,
	(void**)&pPropGpMgr);

stName = SysAllocString(L"Counter");
hr = pPropGpMgr->get_Group(stName, &pPropGp);
SysFreeString(stName);

hr = pPropGp->get_PropertyByPosition
	(0, &pPropNextNum);

// Get the next number and increment the counter.
VariantInit(&vNext);
vNext.vt = VT_I4;
hr = pPropNextNum->get_Value(&vNext);
lNextValue = vNext.lVal++;
hr = pPropNextNum->put_Value(vNext);

© 1997 Microsoft Corporation. All rights reserved.