开发者

Get USB serial number using VB.net?

开发者 https://www.devze.com 2023-01-17 04:45 出处:网络
Can anyone tell me how to get USB serial number(Hardware 开发者_Go百科ID) using VB.net?You should use WMI for this, specifically querying the Win32_USBController Class. The property you want to get is

Can anyone tell me how to get USB serial number(Hardware 开发者_Go百科ID) using VB.net?


You should use WMI for this, specifically querying the Win32_USBController Class. The property you want to get is DeviceID.'

A sample WMI call in the context of a console application might look like this:

Dim mos As New ManagementObjectSearcher("SELECT * FROM Win32_UsbController")

For Each mo As ManagementObject In mos.Get()
    Console.WriteLine(mo.Properties.Item("DeviceID").Value)
Next

Console.ReadLine()

You would need to add references to System.Management and System.Management.Instrumentation to use ManagementObjectSearcher and ManagementObject.

0

精彩评论

暂无评论...
验证码 换一张
取 消