eDosStation/LSWDevices/Device.h
Luc Vandenbroucke 110dc53de7 log
2025-01-09 12:47:42 +01:00

76 lines
No EOL
3.6 KiB
C++

#pragma once
#pragma unmanaged
#define INITGUID
#include <Windows.h>
#include <devguid.h> // for GUID_DEVCLASS_CDROM etc
#include <setupapi.h>
#include <cfgmgr32.h> // for MAX_DEVICE_ID_LEN, CM_Get_Parent and CM_Get_Device_ID
#include <Devpkey.h>
#include <vector>
#pragma comment (lib, "Setupapi.lib")
#pragma comment (lib, "Advapi32.lib")
//#include <iostream>
#include <tchar.h>
#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
#define CLS "USB\\VID_0EBB&PID_0340&MI_00"
#define CLS2 0
#define devstr "USB\\VID_0EBB&PID_0340&MI_00\\7&8520AE7&5&0000"
#define portGuid "4d36e978-e325-11ce-bfc1-08002be10318"
#define USBGuid "88BAE032-5A81-49f0-BC3D-A4FF138216D"
//// include DEVPKEY_Device_BusReportedDeviceDesc from WinDDK\7600.16385.1\inc\api\devpropdef.h
//#ifdef DEFINE_DEVPROPKEY
//#undef DEFINE_DEVPROPKEY
//#endif
//#ifdef INITGUID
//#define DEFINE_DEVPROPKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) EXTERN_C const DEVPROPKEY DECLSPEC_SELECTANY name = { { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }, pid }
//#else
//#define DEFINE_DEVPROPKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) EXTERN_C const DEVPROPKEY name
//#endif // INITGUID
//
//// include DEVPKEY_Device_BusReportedDeviceDesc from WinDDK\7600.16385.1\inc\api\devpkey.h
//DEFINE_DEVPROPKEY(DEVPKEY_Device_BusReportedDeviceDesc, 0x540b947e, 0x8b40, 0x45bc, 0xa8, 0xa2, 0x6a, 0x0b, 0x89, 0x4c, 0xbd, 0xa2, 4); // DEVPROP_TYPE_STRING
//DEFINE_DEVPROPKEY(DEVPKEY_Device_ContainerId, 0x8c7ed206, 0x3f8a, 0x4827, 0xb3, 0xab, 0xae, 0x9e, 0x1f, 0xae, 0xfc, 0x6c, 2); // DEVPROP_TYPE_GUID
//DEFINE_DEVPROPKEY(DEVPKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 14); // DEVPROP_TYPE_STRING
//DEFINE_DEVPROPKEY(DEVPKEY_DeviceDisplay_Category, 0x78c34fc8, 0x104a, 0x4aca, 0x9e, 0xa4, 0x52, 0x4d, 0x52, 0x99, 0x6e, 0x57, 0x5a); // DEVPROP_TYPE_STRING_LIST
//DEFINE_DEVPROPKEY(DEVPKEY_Device_LocationInfo, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 15); // DEVPROP_TYPE_STRING
//DEFINE_DEVPROPKEY(DEVPKEY_Device_Manufacturer, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 13); // DEVPROP_TYPE_STRING
//DEFINE_DEVPROPKEY(DEVPKEY_Device_SecuritySDS, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 26); // DEVPROP_TYPE_SECURITY_DESCRIPTOR_STRING
//DEFINE_DEVPROPKEY(DEVPKEY_Device_UINumberDescFormat, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 31); // DEVPROP_TYPE_STRING
typedef BOOL(WINAPI* fn_SetupDiGetDevicePropertyW)(
__in HDEVINFO DeviceInfoSet,
__in PSP_DEVINFO_DATA DeviceInfoData,
__in const DEVPROPKEY* PropertyKey,
__out DEVPROPTYPE* PropertyType,
__out_opt PBYTE PropertyBuffer,
__in DWORD PropertyBufferSize,
__out_opt PDWORD RequiredSize,
__in DWORD Flags
);
extern TCHAR szDeviceInstanceID[MAX_DEVICE_ID_LEN];
extern WCHAR BusReportedDeviceDesc[255];
extern WCHAR Device_Manufacturer[255];
extern WCHAR Device_FriendlyName[255];
extern WCHAR DeviceDisplay_Category[255];
extern WCHAR Hardware_ID[255];
extern WCHAR PortName[255];
extern CHAR Device_Exclusive;
extern int DeviceIndex;
extern std::vector<const wchar_t* > filters;
inline static void cAddFilter(const wchar_t* filter)
{
const wchar_t* x = _wcsdup(filter);
filters.push_back(x);
}
static BOOL Reset(HDEVINFO hDevInfo, SP_DEVINFO_DATA* pDeviceInfoData);
BOOL DeviceScanEnd();
BOOL DeviceScanStart(int type);
BOOL DeviceScan();