本文整理汇总了C++中CComPtr::AddNdasUnitInstance方法的典型用法代码示例。如果您正苦于以下问题:C++ CComPtr::AddNdasUnitInstance方法的具体用法?C++ CComPtr::AddNdasUnitInstance怎么用?C++ CComPtr::AddNdasUnitInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CComPtr
的用法示例。
在下文中一共展示了CComPtr::AddNdasUnitInstance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: pAllocateID
//.........这里部分代码省略.........
if (itr == m_LogicalUnitDefinitionMap.end())
{
//
// New Logical Device Instance
//
NDAS_LOGICALDEVICE_ID id = pAllocateID();
if (0 == id)
{
UnlockInstance();
// SLOT FULL
hr = NDASSVC_ERROR_LOGICALDEVICE_SLOT_FULL;
return hr;
}
CComObject<CNdasLogicalUnit>* pNdasLogicalUnitInstance;
hr = CComObject<CNdasLogicalUnit>::CreateInstance(&pNdasLogicalUnitInstance);
if (FAILED(hr))
{
XTLTRACE2(NDASSVC_NDASLOGDEVMANAGER, TRACE_LEVEL_ERROR,
"CNdasLogicalUnit::CreateInstance failed, hr=0x%X\n", hr);
UnlockInstance();
return hr;
}
hr = pNdasLogicalUnitInstance->Initialize(id, ludef);
if (FAILED(hr))
{
XTLTRACE2(NDASSVC_NDASLOGDEVMANAGER, TRACE_LEVEL_ERROR,
"CNdasLogicalUnit::Initialize failed, hr=0x%X\n", hr);
UnlockInstance();
return hr;
}
pNdasLogicalUnit = pNdasLogicalUnitInstance;
m_NdasLogicalUnits.Add(pNdasLogicalUnit);
m_LogicalUnitDefinitionMap.insert(std::make_pair(ludef, pNdasLogicalUnit));
m_LogicalUnitIdMap.insert(std::make_pair(id, pNdasLogicalUnit));
UnlockInstance();
CComPtr<INdasDevice> pNdasDevice;
COMVERIFY(pNdasUnit->get_ParentNdasDevice(&pNdasDevice));
XTLASSERT(pNdasDevice);
DWORD regFlags;
COMVERIFY(pNdasDevice->get_RegisterFlags(®Flags));
if (regFlags & NDAS_DEVICE_REG_FLAG_AUTO_REGISTERED)
{
BOOL fMountOnReady = TRUE;
if (NdasServiceConfig::Get(nscMountOnReadyForEncryptedOnly))
{
NDAS_UNITDEVICE_TYPE unitType;
COMVERIFY(pNdasUnit->get_Type(&unitType));
if (0 == luseq && NDAS_UNITDEVICE_TYPE_DISK == unitType)
{
CComQIPtr<INdasDiskUnit> pNdasDiskUnit(pNdasUnit);
ATLASSERT(pNdasDiskUnit.p);
NDAS_CONTENT_ENCRYPT encryption;
COMVERIFY(pNdasDiskUnit->get_ContentEncryption(&encryption));
if (NDAS_CONTENT_ENCRYPT_METHOD_NONE != encryption.Method)
{
fMountOnReady = TRUE;
}
else
{
fMountOnReady = FALSE;
}
}
}
// auto registered devices always ignore RiskyMountFlag
pNdasLogicalUnit->SetRiskyMountFlag(FALSE);
if (fMountOnReady)
{
ACCESS_MASK granted;
pNdasDevice->get_GrantedAccess(&granted);
pNdasLogicalUnit->SetMountOnReady(granted, FALSE);
}
}
}
else
{
pNdasLogicalUnit = itr->second;
UnlockInstance();
}
COMVERIFY(pNdasLogicalUnit->AddNdasUnitInstance(pNdasUnit));
*ppNdasLogicalUnit = pNdasLogicalUnit.Detach();
return S_OK;
}