Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I detect a USB disconnect event? (Windows, .NET C# application)

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?

like image 262
Jon Avatar asked Feb 12 '09 15:02

Jon


People also ask

How do you see what USB devices are disconnecting?

Open the extracted folder and double-click on 'USBDeview.exe' file to run it. A new USBDeview program window will open. You can see the list of all the USB devices that are connected to your PC. ⚪ The Gray dot beside the device name means the device is not connected.

What are USB events?

USB EVENTS cater for Children's Parties, Weddings, Schools, Galas, Fetes & Fun Days, We have full public liability insurance. All castles have up to date test certificates and are tested and we are members of BIHA.

What is USB log?

USBDriveLog is a tool for Windows 10 and Windows 11 that displays a log of all USB drives plugged to your computer. For every USB drive event, the following information is displayed: Device Model, Revision, Manufacturer, Serial Number, Plug Time, Unplug Time, Device ID, Device Capacity, and more...


2 Answers

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

like image 119
Jon Avatar answered Sep 18 '22 09:09

Jon


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

like image 41
Jose Vega Avatar answered Sep 21 '22 09:09

Jose Vega