问题
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.
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.
Thanks in advance
回答1:
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.
After that you should search for it's documentation around here.
来源:https://stackoverflow.com/questions/17325065/is-there-a-way-to-obtain-usb-port-ids-via-win32-api