⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 csetupdi.cpp

📁 bt848,bt878 a采集卡的探测
💻 CPP
字号:
#include "CSetupDi.hpp"

CMemory CDeviceInfoList::GetDeviceRegistryHardwareID(SP_DEVINFO_DATA& DeviceInfoData)
{
	DWORD DataT;
	LPTSTR p = NULL;

	// Unfortunately, no other way to get size on WinMe
	CMemory ret;
	ret.ReSize(1);
	DWORD buffersize = 1;
        
	//
	// We won't know the size of the HardwareID buffer until we call
	// this function. So call it with a null to begin with, and then 
	// use the required buffer size to Alloc the necessary space.
	// Keep calling until we have success or an unknown failure.
	//
	while (!SetupDiGetDeviceRegistryProperty(
            DeviceInfoSet,
            &DeviceInfoData,
            SPDRP_HARDWAREID,
            &DataT,
            (PBYTE)ret.Ptr(),
            ret.Size(),
            &buffersize)) {

		if (GetLastError() == ERROR_INVALID_DATA) {
			// May be a Legacy Device with no HardwareID. Continue.
			break;
		}
		else if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
			// We need to change the buffer size.
			ret.ReSize(ret.Size()+1);
		} else {
			// Unknown Failure.
			break;
        }
	}
	// Return the HardwareIDs
	return ret;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -