I am writing an extension for an existing application that needs to handle USB insertion/removal events. I know the VID/PID of the device of interest. However, I don\'t ha
I followed your "new approach" and also found that OnDeviceChange wasn't being called. The problem was that there was no message loop because it was a Console app. Calling the following function at regular intervals fixed it.
void check_for_device_change()
{
MSG msg;
const int val = PeekMessage( &msg, 0, 0, 0, PM_REMOVE );
if( val > 0 )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}