I currently have a code that sets up notifications about connected USB-HID devices in a Windows service (written in C ++). The code is as follows:
GUID hidGuid; HidD_GetHidGuid(&hidGuid); DEV_BROADCAST_DEVICEINTERFACE NotificationFilter; ZeroMemory(&NotificationFilter, sizeof(NotificationFilter)); NotificationFilter.dbcc_size = sizeof(DEV_BROADCAST_DEVICEINTERFACE); NotificationFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; NotificationFilter.dbcc_classguid = hidGuid; HDEVNOTIFY deviceNotify = RegisterDeviceNotification(StatusHandle, &NotificationFilter, DEVICE_NOTIFY_SERVICE_HANDLE);
The notification is then received through the SERVICE_CONTROL_DEVICEEVENT event. (Remember that this is a Service, therefore there is no WM_DEVICECHANGE).
I thought I could just specify the DEV_BROADCAST_DEVICEINTERFACE flag in the RegisterDeviceNotification () call so that it overrides dbcc_classguid and get all the devices, but it turns out that this flag is not supported in Windows 2000, which is a robber for me. In addition, I assume that this will return more than just USB devices.
How do I change this to get all USB devices, not just USB HID? Should it be as simple as giving a different GUID? Is there a GUID for all USB?
c ++ windows notifications usb
Adam haile
source share