How can I determine which port my device is attached to?
Under Windows, every device has a unique driver key, also called the software key. You can obtain the key from a device using SetupDi functions, and obtain the same key from a hub port using undocumented DeviceIoControl codes. When you have a match, you know which port the device is attached to.
To retrieve the driver key name for a device, call SetupDiGetClassDevs and SetupDiEnumDeviceInfo, then use SetupDiGetDeviceRegistryPropertyA with Property set to SPDRP_DRIVER.
To retrieve the driver key name for a hub port, first find the hubs with SetupDi_ functions and GUID_DEVINTERFACE_USB_HUB.
Obtain a handle to a hub with CreateFile.
Get the number of ports on the hub with IOCTL_USB_GET_NODE_INFORMATION (undocumented IO control code in usbioctl.h).
Find out if a device is attached to a port with IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX.
For each attached device, get the driver key name with IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME (undocumented IO control code in usbioctl.h).
I have two or more identical devices attached to a host. How can I tell which is which?
Store a serial number in the device descriptor or use another vendor-specific identifier. For HID-class devices, applications can read the serial number with the HidD_GetSerialNumberString function.
//usb 编程知识 总结
http://www.cnblogs.com/SunWentao/archive/2011/10/10/2205779.html
//怎么根据设备管理器中的信息取得其对应的串口或驱动器
http://www.myexception.cn/vc-mfc/316257.html
USB基础知识
http://blog.csdn.net/jia_zhengshen/article/category/1405475
//C++/VC 怎么判断USB接口的唯一性
http://www.myexception.cn/cpp/1680062.html
从设备路径怎么得到对应的盘符??或者从盘符得到对应的VID\PID????