📄 csetupdi.hpp
字号:
// 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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -