» 4. VB.NET Sample Code: Generate unique HardwareID with vb.net

                Public Class Form1
                    Public Declare Sub SetLicenseKey Lib "HardwareID.dll" (ByVal LicenseKey As String)
                    Public Declare Sub SetAppName Lib "HardwareID.dll" (ByVal AppName As String)
                    Public Declare Function GetHardwareId Lib "HardwareID.dll" (ByVal HDD As Boolean, ByVal NIC As Boolean, ByVal CPU As Boolean, ByVal BIOS As Boolean, ByVal lpHWID As String, ByVal nMaxCount As Integer) As Integer
                    Public Declare Function IsInsideVMWare Lib "HardwareID.dll" () As Boolean
                    Public Declare Function IsInsideVirtualPC Lib "HardwareID.dll" () As Boolean
                
                    Public Sub New()
                        InitializeComponent()
                    End Sub
                
                    Protected Overrides Sub Finalize()
                        MyBase.Finalize()
                    End Sub
                
                    Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
                        Dim iRetVal As Long
                        Dim lpHWID As String
                
                        If (Not cb_HDD.Checked) And (Not cb_NIC.Checked) And (Not cb_CPU.Checked) And (Not cb_BIOS.Checked) Then
                            textBox1.Text = ""
                            Exit Sub
                        End If
                
                        SetAppName("")
                
                        lpHWID = Space(255)
                
                        iRetVal = GetHardwareId(cb_HDD.Checked, cb_NIC.Checked, cb_CPU.Checked, cb_BIOS.Checked, lpHWID, 255)
                
                        textBox1.Text = lpHWID
                
                    End Sub
                
                    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
                        Dim iRetVal As Long
                        Dim lpHWID As String
                
                        If (Not cb_HDD.Checked) And (Not cb_NIC.Checked) And (Not cb_CPU.Checked) And (Not cb_BIOS.Checked) Then
                            textBox1.Text = ""
                            Exit Sub
                        End If
                
                        SetAppName(TextBox2.Text)
                
                        lpHWID = Space(255)
                
                        iRetVal = GetHardwareId(cb_HDD.Checked, cb_NIC.Checked, cb_CPU.Checked, cb_BIOS.Checked, lpHWID, 255)
                
                        TextBox3.Text = lpHWID
                    End Sub
                
                    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
                        SetLicenseKey("Your-License-Key")
                
                        If IsInsideVMWare() Then
                            LabVmware.Text = "Yes"
                        End If
                
                        If IsInsideVirtualPC() Then
                            LabVirtualPC.Text = "Yes"
                        End If
                    End Sub
                End Class