Public Function funPrintIDUSBDevice()
Dim objWMIService As Object
Dim colItems As Object
Dim objItem As Object
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_DiskDrive", , 48)
For Each objItem In colItems
If objItem.InterfaceType = "USB" Then
Debug.Print "ID: " & Split(objItem.PNPDeviceID, "\")(2)
End If
Next
Set objItem = Nothing
Set colItems = Nothing
Set objWMIService = Nothing
End Function
|