Menampilkan ID Hardware, misalnya Processor ID dengan Visual Basic .NET
1. Buka Visual Studio .NET, Buat New Project. Klik menu File-New Project. Pilih Visual Basic - Windows Application. Klik OK.
2. Dari Toolbox, tambahkan Button ke Form1
3. Klik menu Project-Add Reference, di Tab .NET pilih System.Management
4. Tampilkan kode program Form1.vb. Tambahkan import berikut :
Imports System.Management
5. Klik dua kali Button1, tambahkan kode program berikut ke event Private Sub Button1_Click :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim objMOS As ManagementObjectSearcher Dim objMOC As Management.ManagementObjectCollection Dim objMO As Management.ManagementObject objMOS = New ManagementObjectSearcher("Select * From Win32_Processor") objMOC = objMOS.Get For Each objMO In objMOC MessageBox.Show("CPU ID = " & objMO("ProcessorID")) Next objMOS.Dispose() objMOS = Nothing objMO.Dispose() objMO = Nothing
End Sub
6. Klik menu Debug-Start Debugging (F5) untuk menjalankan program