Hi! All I need to know how can I secure my program by the serial number of local pc or WMI Code Creator? I want to secure my program by client`s hard disk`s serial number so that he cant sell it or use this program there in another pc. Please help me. Is there any tutorial present there to help me? Please help me.

Dani AI

Generated

As asked about locking a program to a client machine and noted the WMI route, here is a practical, modern approach that balances security, reliability and user experience.

Relying on a single hard-disk serial is fragile. Drives are replaced, cloned, reformatted, or virtualized. Prefer a short “hardware fingerprint” made from several stable items (BIOS/motherboard serial, CPU id, a physical disk serial where available, Windows machine GUID). Normalize and concatenate those values, hash them (SHA-256) and treat the result as the machine ID. Issue licenses that embed that machine ID and are cryptographically signed by a private key; the application verifies the signature with an embedded public key and checks the ID match.

Example VB.NET outline (fingerprint generation + SHA-256). This is an implementation sketch — adapt error handling and which WMI classes to query for the environment in production:

Imports System.Security.Cryptography
Imports System.Text
Imports System.Management

Function GetHardwareFingerprint() As String
    Dim parts As New List(Of String)
    ' Query a few hardware fields via WMI (BIOS, CPU, physical media)
    Try
        Using s As New ManagementObjectSearcher("SELECT SerialNumber FROM Win32_BIOS")
            For Each m As ManagementObject In s.Get()
                parts.Add(CStr(m("SerialNumber")))
                Exit For
            Next
        End Using
    Catch ex As Exception
    End Try

    ' Add CPU id and disk serial similarly...

    Dim raw = String.Join("|", parts.Where(Function(p) Not String.IsNullOrEmpty(p)))
    Using sha As SHA256 = SHA256.Create()
        Dim hash = sha.ComputeHash(Encoding.UTF8.GetBytes(raw))
        Return BitConverter.ToString(hash).Replace("-", "").ToLowerInvariant()
    End Using
End Function

Caveats and operational tips: WMI queries can fail (permissions, OS differences, short-lived values). Virtual machines often spoof identifiers. Allow a reactivation workflow or a small hardware-change tolerance, log and rate-limit activations, and keep a support path for legitimate transfers. Protect the verification code (obfuscation, place public key in resources), but avoid "security by obscurity." For serious protection and convenience consider a proven licensing library or an activation server rather than a home-grown scheme.

The question is somehow weird. you need to use then WMI class to get the disk serial.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.