title: How do I detect when a device attached to the system is ready for use?
body: <p>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 <a href="http://msdn.microsoft.com/en-us/library/aa363858%28VS.85%29.aspx" rel="nofollow noreferrer">CreateFile()</a> function always returns an error: <strong>ERROR_GEN_FAILURE 31 (0x1F)</strong> which translates to -<strong>A device attached to the system is not functioning</strong>, this is however, attempted after recieving the <strong>DBT_DEVICEARRIVAL</strong> message which by <a href="http://msdn.microsoft.com/en-us/library/aa363480%28VS.85%29.aspx" rel="nofollow noreferrer">microsoft's</a> own definition says "<strong>A device or piece of media has been inserted and is now available</strong>". 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?</p>