I've managed to check if a USB device is inserted through WM_DEVICECHANGE
.
case WM_DEVICECHANGE:
{
PDEV_BROADCAST_HDR lpdb = (PDEV_BROADCAST_HDR)lParam;
switch(wParam)
{
case DBT_DEVICEARRIVAL:
{
if (lpdb->dbch_devicetype == DBT_DEVTYP_VOLUME)
{
// Get Information about the usb device inserted
}
return TRUE;
}
}
}
Now, I want to make sure that a right usb device was inserted by matching some kind of IDs and also I'll need to check the space available on the USB device.
One solution I can tell is to iterate through all the hardware devices until one matches with the information.
is there any another way to recognize the device upon insertion?