在 Visual Basic 中获取驱动程序的状态

Get Status of Driver Inside Visual Basic

我目前正在尝试检测哪些驱动程序在 Visual Basic 中显示为 "not working"。

This unknown device is a good example 我要抓取的内容(注意它如何具有标志 DN_HAS_PROBLEM)。

我试过使用以下搜索:

Dim searcher As New ManagementObjectSearcher( "root\CIMV2", "SELECT * FROM Win32_SystemDriver")

和运行 searcher.Get() 到this documentation

中的一个循环

然而,其中 none 似乎 return 我正在寻找的东西。

有没有人知道如何在 Visual Basic 中获取 DN_ 状态?

谢谢!

The Win32_SystemDriver class documentation 列出了这些 Status 属性:

OK
Error
Degraded
Unknown
Pred Fail
Starting
Stopping
Service
Stressed
NonRecover
No Contact
Lost Comm

...而 DN_HAS_PROBLEM 来自 CM_Get_DevNode_Status 函数,或者也可能来自其他系统调用。

可能无法从您正在使用的 API 中获取该特定代码,但也许现有的 Status 属性就足够了如果您不需要知道更具体的失败原因,可以满足您的需求。

如果你确实需要知道那个特定的状态,你将不得不呼叫其他APIs,就像我呼叫的那样。