C# 重新挂载USB设备
我有一个 USB 设备,有时会“丢失”(只是不再工作,可能是因为驱动程序或产品本身不太好)。但是,我编写的应用程序依赖于该设备。要让设备再次工作,我需要做的就是将其拔出并重新插入。
我想知道我是否可以通过我的 C# 应用程序自动执行此操作?比如禁用并重新启用 USB 端口?
Possible Duplicate:
How to programatically unplug & replug an arbitrary USB device?
I have a USB device that sometimes 'gets lost' (just doesn't work anymore, probably because the driver or the product itself is not so good). however, an application I write relies on this device. what i need to do to get the device working again is plugging it out and in again.
I want to know whether i can do that somehow automatically from my C# application? like disabling and reenabling the usb port?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我了解,在Windows下,您可能无法物理模拟设备的移除和插回,但您可以尝试禁用该设备然后启用它。
查看SetupApi.dll,
了解如何在 C# 中执行此操作,您可以查看以下链接
Win32 API 函数以编程方式启用/禁用设备
From what I understand, under windows, you might not be able to physically simulate the device remove and plug in back, but you can try disable the device and then enable it.
take a look at the SetupApi.dll
regarding how to do that in C# you can take a look at the following link
Win32 API function to programatically enable/disable device