C# 重新挂载USB设备

发布于 2024-12-26 22:54:46 字数 360 浏览 1 评论 0原文

可能的重复:
如何以编程方式拔出和插入重新插入任意 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

随梦而飞# 2025-01-02 22:54:46

据我了解,在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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文