当前位置: 首页>>代码示例>>C++>>正文


C++ CComPtr::AddNdasUnitInstance方法代码示例

本文整理汇总了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(&regFlags));

		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;
}
开发者ID:tigtigtig,项目名称:ndas4windows,代码行数:101,代码来源:ndaslogdevman.cpp


注:本文中的CComPtr::AddNdasUnitInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。