【问题标题】:Programmatically restart USB device in Windows在 Windows 中以编程方式重新启动 USB 设备
【发布时间】:2011-03-09 22:48:15
【问题描述】:
我正在开发的某些软件需要 USB 设备(我作为 SerialPort 与之交互,带有 USB 到 UART 桥接器)。
有时,在计算机从休眠状态重新启动后,无法检测到设备,我无法再通过其串行端口写入或读取设备。必须拥有对设备的读/写权限。
我不能依赖用户采取任何行动(物理或其他方式),因此我需要一种以编程方式重新启动设备的方法。
我应该如何在 Windows XP/Vista/7 中使用 .NET 框架以编程方式重新启动 USB 设备?
【问题讨论】:
标签:
.net
windows
usb
systems-programming
hardware-programming
【解决方案1】:
您可以使用WDK(Windows 驱动程序工具包)。提供了大量源代码示例,但预计学习曲线会很陡峭。
Devcon 是由 MS 开发的一个程序,用于演示目的,有时可以工作并做你想做的事。但请注意,这很奇怪和狂野。反正提供了源代码,所以如果你喜欢乱搞设备驱动,你可以滚自己的“Devcon”代码。
来自 MS 网站:
DevCon (Devcon.exe), the Device Console, is a command-line tool that displays
detailed information about devices. Using DevCon, you can search for and
manipulate devices from the command line. DevCon enables, disables, installs,
configures, and removes devices on the local computer and displays detailed
information about devices on local and remote computers.
HTH!