Yes but maybe not the right way.
I use MFC C++... So I could not find the IsInvalid property.
In GetHidCollectionDevice, I have:
DeviceHandle=CreateFile
(aDetailData[HIDDeviceIndex]->DevicePath,
0,
FILE_SHARE_READ|FILE_SHARE_WRITE,
(LPSECURITY_ATTRIBUTES)NULL,
OPEN_EXISTING,
0,
NULL);
if(DeviceHandle == INVALID_HANDLE_VALUE)
{
return GetLastError();
}
I put a breakpoint on "return GetLastError();", but it never breaks after I removed both device. The second device is still in the list as if it was connected. I can handle the crash of the software but how can I detect that the device is gone, instead of having to wait 5 secs until the plug and play sound is heard?
In CreateFile, I use for OPEN_EXISTING for the parameter dwCreationDisposition [in], I also tried CREATE_ALWAYS but it did not work. Could this be a problem?
Thanks