下面是获取U盘物理序列号的代码(加密狗也行): Public Sub QW() Dim objWMIService As Object Dim colItems As Object Dim objitem As Object Dim a, b, c, d, e, U_Dist Set objWMIService = GetObject("winmgmts:\\.\root\cimv2") Set colItems = objWMIService.ExecQuery("Select * From Win32_USBHub") For Each objitem In colItems a = objitem.DeviceID If a Like "*VID*" Then b = Split(a, "\") c = Split(b(UBound(b) - 1), "&") d = Split(c(UBound(c) - 1), "_") e = Split(c(UBound(c)), "_") 'ÒÔÉÏ»ñÈ¡³öÏà¹Ø²ÎÊý U_Dist = d(UBound(d)) + e(UBound(e)) + b(UBound(b)) [A1] = U_Dist End If Next End Sub
|