是否可以以编程方式为Windows中的设备识别物理USB端口? [英] Can the physical USB port be identified programmatically for a device in Windows?

查看:144
本文介绍了是否可以以编程方式为Windows中的设备识别物理USB端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个USB设备,该设备在收到命令时具有不同的接口,VID,PID和序列号,我想在发生此更改后跟踪物理设备。我的想法是通过集线器和端口位置对其进行跟踪。

I have a USB device that enumerates with a different interface, VID, PID and serial number when commanded to do so, and I'd like to keep track of the physical device after this change occurs. My thought was to track it by its hub and port location.

Win32_PnPSignedDriver 类的位置字段似乎很完美(例如 Port_#0001 .Hub_#0010 ),但仅包含首次加载驱动程序时设备的位置。将硬件插入其他端口不会更新该字段。

The Win32_PnPSignedDriver class has a "Location" field that seemed perfect (e.g. Port_#0001.Hub_#0010), but it only contains the location of the device when the driver was first loaded. Plugging the hardware into a different port does not update that field.

但是,该信息在某处可用,因为详细信息选项卡下有一个位置信息字段通过设备管理器查看设备时。是否可以通过 WMI查询或某些信息来检索此信息其他方法?有解决这个问题的更好方法吗?

However, the information is available somewhere because there is a "Location information" field under the "Details" tab when viewing the device via the Device Manager. Can this information be retrieve through WMI queries or some other method? Is there a better approach to solving this problem?

编辑:我知道这听起来很奇怪。这些设备中的微控制器包含一个ROM,该ROM枚举为CDC设备(即串行端口)并允许编程。在制造过程中,跟踪在制造商的ROM(唯一的VID / PID /序列号)和我的自定义固件接口(不同的VID / PID /序列号)之间切换的设备将是有益的。

I know this sounds like a strange scenario. The microcontroller in these devices contains a ROM that enumerates as a CDC device (i.e. serial port) and allows programming. During manufacturing, it would be beneficial to track a device as it changes between the manufacturer's ROM (unique VID/PID/serial number) and my custom firmware interface (different VID/PID/serial number).

推荐答案

据我所知,在Windows中无法将USB设备与物理端口相关联。请随时证明我错了。

As best as I can tell, correlating a USB device with a physical port is not possible in Windows. Please feel free to prove me wrong.

这篇关于是否可以以编程方式为Windows中的设备识别物理USB端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆