vb.net怎么获取硬盘的序列号
vb.net如何获取硬盘的序列号
vb.net如何获取硬盘的序列号,注意不是盘符的,谢谢
------解决方案--------------------
http://www.docin.com/p-374146154.html
------解决方案--------------------
vb.net如何获取硬盘的序列号,注意不是盘符的,谢谢
------解决方案--------------------
http://www.docin.com/p-374146154.html
------解决方案--------------------
- VB.NET code
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
------解决方案--------------------
这种东西网上一搜一大把,复杂么?别人都封装好了。你拿来直接粘贴用就行了。这都觉得复杂,的确过分了有点。
- VB.NET code
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