有没有办法通过 Win32 API 获取 USB 端口 ID? [英] Is there a way to obtain USB port IDs via Win32 API?

查看:59
本文介绍了有没有办法通过 Win32 API 获取 USB 端口 ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种方法来获取我正在处理的项目中 USB 端口(如果存在)的 ID.我们试图做的是通过使用 USB 端口将一些 Asus 深度摄像头连接到 Windows 计算机,并在我们的应用程序中使用这些摄像头来唯一标识摄像头,因为每个摄像头都有一些为其生成的特定信息(一些变换矩阵等)并为每个相机重新加载此信息,当我们断开相机并再次将相机重新连接到计算机时.看起来我们用来控制深度传感器 (OpenNI) 的 API 没有提供特定于设备的唯一 ID,因此我们正在考虑使用 USB 端口的 ID,而不是设备并专门生成我们的数据使用 USB 端口 ID;这样我们就知道相机应该如何"定位,例如,如果它连接到特定"的 USB 端口.

I am in need of a way to obtain the IDs of the USB ports (if they exist) in a project I am working on. What we are trying to do is to connect some Asus depth cameras to a Windows-computer by using USB ports and in our application, which makes use of these cameras,to uniquely identify a camera because each camera has some specific information generated for it (some transformation matrices, etc.) and to reload this information for each camera, when we disconnect and reconnect the cameras to the computer again. Looks like that the API we are using in order to control the depth sensors (OpenNI) does not provide a device specific, unique ID, so we are thinking about using the IDs of the USB ports, rather than the devices and generate our data specifically using the USB port IDs; such that we know "how" a camera should positioned, for example, if it is connected to a "specific" USB port.

我有两个问题.首先,Windows系统上的USB端口是否有这样的唯一标识符;我们可以以某种方式区分不同的 USB 端口吗?(我在这里有点怀疑,因为它们最终连接到总线.)我的第二个问题是,如果我们可以区分和枚举 USB 端口,我们如何使用 Win32 API 或其他一些库来做到这一点?我遇到了称为Windows Management Instrumentation"的东西及其相应的类.有一个名为Win32_USBController"的类,我认为这可能包含我需要的东西,但我不知道如何使用它.所以我转向这里寻求帮助.

I have two questions here. First, do the USB ports on a Windows system have such unique identifiers; can we distinguish different USB ports somehow? (I am a bit skeptical here, since they are connected a bus, in the end.) My second question is, if we can distinguish and enumerate USB ports, how can we do that by using the Win32 API or some other library? I came across something called as the "Windows Management Instrumentation" and its corresponding classes. There is a class called "Win32_USBController" and I think this may contain what I need, but I don't have any clue about how to use it. So I turned here for help.

提前致谢

推荐答案

我唯一能提出的建议是,在没有实际看到您的摄像头或不知道它们是什么型号的情况下,将它们全部插入,打开设备管理器,找到这些摄像头在那里,切换到详细信息"选项卡,然后找到所有相机都不同的属性.

The only thing I can propose, without actually seeing your cameras or knowing what model they are, is to plug them all in, open Device Manager, locate those cameras there, switch to "Details" tab and then find property, which differs for all cameras.

之后,您应该在 这里.

这篇关于有没有办法通过 Win32 API 获取 USB 端口 ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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