简体   繁体   中英

c++ windows get Usb port and hub by USB serial

I'm trying to capture video from usb webcam, what is connected to a certain usb port (I have many same cameras connected). I have a code that makes USB Device Path for all webcams. I have something like:

\\?\usb#vid_0c45&pid_614a#5&18f54cb7&0&2#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global

Where: 5&18f54cb7&0&2 - USB serial string. I cant use pid and vid because I have other same webcams.

How can I get usb port and hub knowing USB serial?

The hub is the parent of the webcam, so you find it via SetupDiGetDeviceProperty property DEVPKEY_Device_Parent . USB port is DEVPKEY_Device_LocationInfo .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM