16,555
社区成员
发帖
与我相关
我的任务
分享
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'需要引用 Imports Scripting
ListBox1.Items.Clear()
Try
Dim cmicWmi As New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")
Dim Uint32 As Long = 0
For Each cmicWmiObj As Management.ManagementObject In cmicWmi.Get
Uint32 = cmicWmiObj("signature") '必须要用 signature
ListBox1.Items.Add(Uint32.ToString)
Next
TextBox1.Text = Uint32.ToString
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Sub
Dim cmicWmi As New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")
Dim Uint32 As UInt32
For Each cmicWmiObj As ManagementObject In cmicWmi.Get
Uint32 = cmicWmiObj("signature")
Next
TextBox1.Text = Uint32.ToString
'获得CPU序列号
Dim Wmi As New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_Processor")
Dim Uint32 As String
For Each WmiObj As ManagementObject In Wmi.Get
Uint32 = WmiObj("ProcessorId")
Next
TextBox1.Text = Uint32
'获得硬盘总容量
Dim Wmi As New System.Management.ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")
Dim Uint64 As UInt64
For Each WmiObj As ManagementObject In Wmi.Get
Uint64 = WmiObj("size")
Next
TextBox1.Text = Uint64.ToString