如何获取USB设备的序列号?

比如联想A710e,用adb可以获取到其序列号是“A710e”:
D:\pcsuit\bin\Adb>adb devices
List of devices attached
A710e   device

如果用程序获取到其序列号呢?

该序列号在注册表项【HKEY_LOCAL_MACHINE\System\CurrentControlSet\Enum\USB】下能找到!

但是,从注册里读取出来的序列号信息,不一定准确。
比如联想A68e的序列号里有空格,但注册表里把空格替换成下划线了:

但它实际的序列号是"A68e            "。
可以用usbview,通过DeviceIoControl()直接读取硬件设备信息,获取到的。
用adb.exe命令对它进行操作,也必须使用有空格的真实序列号,否则,操作是会失败的。如:
D:\pcsuite\bin\Adb>adb -s "A68e" shell am startservice -a skymobi_tcpservice
error: device not found
D:\pcsuite\bin\Adb>adb -s "A68e____________" shell am startservice -a skymobi_tcpservice
error: device not found
D:\pcsuite\bin\Adb>adb -s "A68e            " shell am startservice -a skymobi_tcpservice
Starting service: Intent { act=skymobi_tcpservice }

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值