百度找到一段代码,在狐表里面怎么使用GetUSBSerialNumbers?如何导入命名空间System.Management
'Imports System.Management
Public Function GetUSBSerialNumbers() As List(Of String)
Dim serialNumbers As New List(Of String)()
Dim query As New SelectQuery("Win32_DiskDrive", "InterfaceType='USB'")
Dim searcher As New ManagementObjectSearcher(query)
For Each drive As ManagementObject In searcher.Get()
Dim pnpDeviceID As String = drive("PNPDeviceID").ToString()
Dim deviceIdParts As String() = pnpDeviceID.Split("\"c)
Dim deviceId As String = deviceIdParts(deviceIdParts.Length - 1)
Dim query2 As New SelectQuery("Win32_PhysicalMedia", "Tag='" & deviceId & "'")
Dim searcher2 As New ManagementObjectSearcher(query2)
For Each drive2 As ManagementObject In searcher2.Get()
Dim serialNumber As String = drive2("SerialNumber").ToString()
If Not String.IsNullOrEmpty(serialNumber) Then
serialNumbers.Add(serialNumber.Trim())
End If
Next
Next
Return serialNumbers
End Function