Link to home
Start Free TrialLog in
Avatar of XK8ER
XK8ERFlag for United States of America

asked on - serial number

hello there,
I would like to generate a serial number from a specific computer.. what im using right now is I get the hard drive serial from registry and then I generate the license for the software..
the issue with this is that if the client reinstall windows or upgrades from XP to W7 then the registry serial changes.. is it possible to get hard drive serial number or CPU serial number
or something some the actual machine hardware and not from registry?
Avatar of rockiroads
Flag of United States of America image

Avatar of XK8ER


mac address can be easily spoofed
Get Hard Disk Serial and CPUID in .Net

Public Function GetHDSerial() As String
   Dim disk As New ManagementObject(_
   Dim diskPropertyA As PropertyData = _
   Return diskPropertyA.Value.ToString()
End Function
Public Function GetCPUId() As String
   Dim cpuInfo As String = String.Empty
   Dim temp As String = String.Empty
   Dim mc As ManagementClass = _
       New ManagementClass("Win32_Processor")
   Dim moc As ManagementObjectCollection =_
   For Each mo As ManagementObject In moc
     If cpuInfo = String.Empty Then
        cpuInfo = _
     End If
   Return cpuInfo
End Function

Open in new window

Some other interesting articles about licensing

Licensing a VB.Net application

Applications Licensing using the .NET Framework

Really Simple Licensing Scheme for .NET

Using XML Digital Signatures for Application Licensing

Eziriz's Intelilock:

Avatar of XK8ER


Dhaest, that hard drive serial number can be easily spoofed too since its coming from the registry!
For your information: Usually, the serial number of a drive is generated every time you format your hard drive and there is no documented way to change it afterwards.


Determine harddrive numbers:
why dont u try a combination of id's
How To Get Hardware Information (CPU ID, MainBoard Info, Hard Disk Serial, System Information , ...)
Avatar of XK8ER


Dhaest, saw that already and that's not really directly from hardware but from registry..
Avatar of xiong8086

I think may be MAC address of the network card is the one can be captured for your requirements, as it will not change with software reinstallation.
My opinion: The only annoying this for any user is that if the network card failes, the harddisk crashes (and be replaced), ... that the program won't work anymore (without re-paying ?)
How to Retrieve the REAL Hard Drive Serial Number
Avatar of XK8ER


yes but this is a section and question not C
Avatar of XK8ER


and that C# also gets the hard drive serial from registry

ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia")
>> gets the hard drive serial from registry

Everything always will be retrieved through the registry. What's not in there, is also not in the system !

FYI: I converted the code below (but I didn't get any serial number)
        Dim hdCollection As List(Of HardDrive) = New List(Of HardDrive)

        Dim searcher As New ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive")

        For Each wmi_HD As ManagementObject In searcher.[Get]()
            Dim hd As New HardDrive()
            hd.Model = wmi_HD("Model").ToString()
            hd.Type = wmi_HD("InterfaceType").ToString()

        searcher = New ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia")

        Dim i As Integer = 0
        For Each wmi_HD As ManagementObject In searcher.[Get]()
            ' get the hard drive from collection
            ' using index
            Dim hd As HardDrive = DirectCast(hdCollection(i), HardDrive)

            ' get the hardware serial no.
            If wmi_HD("SerialNumber") Is Nothing Then
                hd.SerialNo = "None"
                hd.SerialNo = wmi_HD("SerialNumber").ToString()
            End If

            i += 1

        For Each hd As HardDrive In hdCollection
            Console.WriteLine("Model" & vbTab & vbTab & ": " + hd.Model)
            Console.WriteLine("Type" & vbTab & vbTab & ": " + hd.Type)
            Console.WriteLine("Serial No." & vbTab & ": " + hd.SerialNo)

Open in new window

Avatar of XK8ER


Inteqam, look at the section please..

    * Home
    * Programming
    * Prog Languages
    * .NET Programming
    * Visual Basic.NET
    * - serial number

i did, but if you have a clasic vb com or dll, you can easily use it in

BTW: i saw a dll that claims it gets the manufacturer serial, but it is not free, interested?
Avatar of XK8ER


well I have a source code in VB6 project that when you click the button it shows you the real HD serial number.. how can I convert that into a dll file to use with instead?
Avatar of Dirk Haest
Dirk Haest
Flag of Belgium image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial