使用 WMI 查询的串行端口列表与设备管理器不同? [英] List of SerialPorts queried using WMI differs from devicemanager?
问题描述
我的设备管理器中列出了以下串行端口:
I have the following serial ports listed in my devicemanager:
- COM3
- COM4 (BT)
- COM5 (BT)
- COM6(GlobeTrotter MO67xx - 控制接口)
- COM7(GlobeTrotter MO67xx - GPS 控制接口)
- COM8(GlobeTrotter MO67xx - GPS 数据接口)
- COM9(GlobeTrotter MO67xx - 诊断接口)
- COM11(USB 串行端口)
- COM12(USB 串行端口)
- COM45(SUNIX COM 端口)
- COM46(SUNIX COM 端口)
SUNIX COM 端口通过内部 PCI 卡连接.USB Serial Port 通过 USB(FDTI 芯片)连接GlobeTrotter 端口来自通过 USB 连接的 GlobeTrotter 设备.此调制解调器还列出了一个调制解调器、一个 USB 设备和一个网络设备.
The SUNIX COM ports are connected via an internal PCI-Card. The USB Serial Port is connected via USB (FDTI-chip) The GlobeTrotter ports are from a GlobeTrotter device connected via USB. There are also a modem, a USB-device and a network device listed for this modem.
所以我有几个不同的串口来源.
So I have several different sources of serial ports.
我想要做的就是使用 WMI 获取包含所有这些端口的列表.
All I want to do is to get a list containing all those ports using WMI.
对于我的测试,我使用 WMI Code Creator
For my tests I am using WMI Code Creator
测试 1:
root\CIMV2
;查询:SELECT * FROM Win32_SerialPort
只返回以下串口:
root\CIMV2
; Query: SELECT * FROM Win32_SerialPort
only returns the following serial ports:
- COM3
- COM4
- COM5
测试 2:
root\WMI
;查询:SELECT * FROM MSSerial_PortName
只返回以下串口:
root\WMI
; Query: SELECT * FROM MSSerial_PortName
only returns the following serial ports:
- COM3
- COM11
- COM12
- COM45
- COM45
如何获得完整的串口列表?
How can I get a complete list of serial ports?
推荐答案
我找到了解决方案.
以下查询 (root\CIMV2
) 获取请求的结果:
The following query (root\CIMV2
) gets the requested results:
SELECT * FROM Win32_PnPEntity WHERE ClassGuid="{4d36e978-e325-11ce-bfc1-08002be10318}"
<小时>
更新
这个答案现在已经很老了.Ehen我问它我仍然必须考虑WinXP并且使用Windows7.由于我不再处理串行端口,因此我无法提供有关该问题的任何新信息.当时这个解决方案报告了设备管理器显示的所有端口.但我知道列出串行端口并不是那么容易,所以这个答案可能并非在所有情况下都正确.
This answer is pretty old now. Ehen I asked it I still had to consider WinXP and was using Windows7. Since I don't deal with serial ports any more, I can't give any new information on that issue. At that time this solution reported all ports that the devicemanager was showing. But I know listing serial ports is not that easy so this answer might not be correct in all scenarios.
这篇关于使用 WMI 查询的串行端口列表与设备管理器不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!