Thursday, April 28, 2011

How do I detect when a device attached to the system is ready for use?

Hi all

I'm sorry if this is similar to an earlier question but this is something I just noticed. I can detect when my device is attached to the system (via usb) and trap the message correctly however if I unplug and plug the device back, attempting to access the device via the CreateFile() function always returns an error: ERROR_GEN_FAILURE 31 (0x1F) which translates to -A device attached to the system is not functioning, this is however, attempted after recieving the DBT_DEVICEARRIVAL message which by microsoft's own definition says "A device or piece of media has been inserted and is now available". I believe what's going on here is that the error has more to do with the device not being ready even though it's reported as being ready because if I re-enumerate the list of devices on the system again, the device is ready. Has anyone else encountered and gotten past this problem? Or is there something I'm missing/overlooking?

From stackoverflow

0 comments:

Post a Comment