在Windows中以编程方式重新启动USB设备

我正在开发的一些软件需要有一个USB设备(我将它作为一个SerialPort与一个USB-to-UART桥接器进行交互)。

有时,计算机从hibernate状态重新启动后,设备未被检测到,我不能再通过其串行端口写入或读取设备。 有读/写访问设备是必要的。

我不能依靠用户采取任何行动(物理或其他),所以我需要一种方式来以编程方式重新启动设备。

我应该如何在Windows XP / Vista / 7中使用.NET框架以编程方式重新启动USB设备?

您可以使用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!