USB相关知识

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????

http://www.debugease.com/vc/2586359.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值