HOW TO:检索本机硬件信息
使用ManagementClass。下面的示例是检索硬盘信息的。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim disks As New ManagementClass("Win32_DiskDrive")
Dim observer As New ManagementOperationObserver
AddHandler observer.ObjectReady, AddressOf OnEnumObjectReady
disks.GetInstances(observer)
End Sub
Sub OnEnumObjectReady(ByVal sender As Object, ByVal e As ObjectReadyEventArgs)
Console.WriteLine("******************************************************")
Console.WriteLine(e.NewObject.Properties("Description").Value)
Console.WriteLine(e.NewObject.Properties("Caption").Value)
Console.WriteLine(e.NewObject.Properties("DeviceID").Value)
End Sub