csetupdi.hpp
来自「bt848,bt878 a采集卡的探测」· HPP 代码 · 共 45 行
HPP
45 行
// Helper class with SetupDi.. fns
#ifndef _CSETUPDI_HPP
#define _CSETUPDI_HPP
#include <windows.h>
#include <setupapi.h> // for SetupDiXxx functions.
#include <newdev.h>
#include "CMemory.hpp"
#include "CString.hpp"
class CDeviceInfoList {
protected:
HDEVINFO DeviceInfoSet; // Handle to the Set
public:
// Create a Device Information Set with all present devices.
CDeviceInfoList() : DeviceInfoSet(INVALID_HANDLE_VALUE) {
DeviceInfoSet = SetupDiGetClassDevs(NULL, // All Classes
0,
0,
DIGCF_ALLCLASSES | DIGCF_PRESENT ); // All devices present on system
}
// To know if the Query is open
bool IsOpen() const { return (DeviceInfoSet!=INVALID_HANDLE_VALUE); }
// To enum the Device Info
bool EnumDeviceInfo(ULONG i,SP_DEVINFO_DATA& DeviceInfoData) {
return SetupDiEnumDeviceInfo(DeviceInfoSet,i,&DeviceInfoData)==TRUE;
}
// To Get the Device registry Hardware IDs.
CMemory GetDeviceRegistryHardwareID(SP_DEVINFO_DATA& DeviceInfoData);
// To call the class installer/uninstaller
bool CallClassInstaller(UINT code,SP_DEVINFO_DATA& DeviceInfoData) {
return SetupDiCallClassInstaller(code, DeviceInfoSet,&DeviceInfoData)==TRUE;
}
// To release a Query
~CDeviceInfoList() { if (IsOpen()) SetupDiDestroyDeviceInfoList(DeviceInfoSet); }
};
#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?