17

Currently how I do this is I poll for a masked list of USB devices (masked specifically for the device I'm working with) and if it's there, I continue, if not then I notify the user that the device is not connected. The method for getting a list of USB devices is provided for me through a USB peripheral controller chip manufacturer's .NET library.

Is there an event somewhere for a USB device disconnect?

Jon
  • 1,379
  • 1
  • 12
  • 32
  • I made a NuGet packet that works on Windows, MacOS and Linux: https://github.com/Jinjinov/Usb.Events – Jinjinov Apr 28 '20 at 06:27

2 Answers2

13

I ended up using this: http://msdn.microsoft.com/en-us/library/aa363480(VS.85).aspx

And followed this: http://www.codeproject.com/KB/system/DriveDetector.aspx

Jeff Atwood
  • 63,320
  • 48
  • 150
  • 153
Jon
  • 1,379
  • 1
  • 12
  • 32
3

have you checked out the Win32_USBControllerDevice class? http://msdn.microsoft.com/en-us/library/aa394505(VS.85).aspx

Jeff Atwood
  • 63,320
  • 48
  • 150
  • 153
Jose Vega
  • 10,128
  • 7
  • 40
  • 57
  • I should clarify; I'm actually using a USB peripheral controller chip (big difference, should've worded that better) I'll look into that class, thanks Jose. Also, I did find this too: http://msdn.microsoft.com/en-us/library/aa363480(VS.85).aspx WM_DEVICECHANGE – Jon Feb 12 '09 at 15:33