本文整理汇总了C++中CComQIPtr::GetCustomPropertyBag方法的典型用法代码示例。如果您正苦于以下问题:C++ CComQIPtr::GetCustomPropertyBag方法的具体用法?C++ CComQIPtr::GetCustomPropertyBag怎么用?C++ CComQIPtr::GetCustomPropertyBag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComQIPtr
的用法示例。
在下文中一共展示了CComQIPtr::GetCustomPropertyBag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: propName
HRESULT
AsdkSheetSet::addCustomProperty(char* key, // Property name
char* value, // Property value
IAcSmComponent *pComp, // Component to add custom properties to
PropertyFlags propertyFlag) // Property flag which specifies
// whether to inherit properties
// for all sheets in the sheet set
// or to only apply at sheet set level
{
if(FAILED(isInitialized("addCustomProperty")))
return E_FAIL;
CComQIPtr<IAcSmComponent> pCmp;
if (!pComp)
// if null, create properties for sheet set
pCmp = m_pSheetSet;
else
pCmp = pComp;
// lock the the database first before doing any operation on it
if (FAILED(LockDatabase()))
{
acutPrintf("\n Database lock failed!");
return E_FAIL;
}
// Add one custom property at the sheet set level
CComPtr<IAcSmCustomPropertyBag> pBag = NULL;
if(FAILED(pCmp->GetCustomPropertyBag(&pBag)))
{
acutPrintf("\nError: custom property bag.");
return E_FAIL;
}
CComPtr<IAcSmCustomPropertyValue> pPropVal;
if (FAILED(pPropVal.CoCreateInstance(L"AcSmComponents.AcSmCustomPropertyValue")))
{
acutPrintf("\nError: initializing custom property.");
return E_POINTER;
}
if(FAILED(pPropVal->InitNew(pBag)))
{
acutPrintf("\nError: initializing custom property value.");
return E_FAIL;
}
HRESULT hr;
// set the property flag.
if(FAILED(( hr = pPropVal->SetFlags((PropertyFlags)propertyFlag))))
{
acutPrintf("\nError: setting custom property flag.");
return E_FAIL;
}
// set the property name(key)
CComBSTR propName(key);
if(FAILED(pBag->SetProperty(propName, pPropVal)))
{
acutPrintf("\nError: attaching custom property to sheet set.");
return E_FAIL;
}
// set the property value(for the key)
CComVariant val(value);
if(FAILED(pPropVal->SetValue(val)))
{
acutPrintf("\nError: setting custom property value.");
return E_FAIL;
}
// Unlock database
if (FAILED(UnlockDatabase()))
{
acutPrintf("\n Cannot unlock database");
return E_FAIL;
}
return S_OK;
}