How to detect USB device arrival and removal.
Posted on 2004-04-29
Could you please let me know how to detect USB device arrival. Am writing a windows 32 application using SDK which would detect arrival of any device at USB port. After detecting the device it would get device handle and then later to get details of the device using it's handle.
MSDN describes all top windows will recieve WM_DEVICECHANGE message with DBT_DEVICEARRIVAL and DBT_DEVICEREMOVECOMPLETE; upon inserting and removing the device respetively into the PC. Unfortunately I do not recieve these messages/events whenever I insert a device or remove it. However, I could receive these messages whenever I inserted a CD_ROM. Does this mean that windows deliver these messages only when CD_ROM device is inserted into the disk?
Then I thought; I should be using RegisterDeviceNotification but the remarks on this API indicates that I need not register in order to recieve above events and more over no registration is required for volume type devices either.
I will be greatful to you if you could help me in resolving this most nagging problem.