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

隐身守侯 提交于 2020-01-01 01:49:12

问题


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?


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/541765/how-can-i-detect-a-usb-disconnect-event-windows-net-c-sharp-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!