Solved

vb.net - serial number

Posted on 2010-09-07
21
2,635 Views
Last Modified: 2012-05-10
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?
0
Comment
Question by:XK8ER
  • 7
  • 7
  • 4
  • +2
21 Comments
 
LVL 65

Expert Comment

by:rockiroads
ID: 33624365
0
 
LVL 1

Author Comment

by:XK8ER
ID: 33624376
mac address can be easily spoofed
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 33624405
Get Hard Disk Serial and CPUID in .Net
http://www.aboutmydot.net/index.php/cpuid-net-hd-serial

Public Function GetHDSerial() As String
   Dim disk As New ManagementObject(_
       "Win32_LogicalDisk.DeviceID=""C:""")
   Dim diskPropertyA As PropertyData = _
       disk.Properties("VolumeSerialNumber")
   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 =_
       mc.GetInstances()
   For Each mo As ManagementObject In moc
     If cpuInfo = String.Empty Then
        cpuInfo = _
         mo.Properties("ProcessorId").Value.ToString()
     End If
   Next
   Return cpuInfo
End Function

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 53

Expert Comment

by:Dhaest
ID: 33624414
Some other interesting articles about licensing

Licensing a VB.Net application
http://www.emoreau.com/Entries/Articles/2007/12/Licensing-a-VBNet-application.aspx

Applications Licensing using the .NET Framework
http://www.developer.com/net/csharp/article.php/3074001/Applications-Licensing-using-the-NET-Framework.htm

Really Simple Licensing Scheme for .NET
http://jclement.ca/devel/dotnet/reallysimplelicensing.html

Using XML Digital Signatures for Application Licensing
http://www.codeproject.com/KB/security/xmldsiglic.aspx

Eziriz's Intelilock:
http://www.eziriz.com/downloads.htm

0
 
LVL 1

Author Comment

by:XK8ER
ID: 33624416
Dhaest, that hard drive serial number can be easily spoofed too since its coming from the registry!
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 33624445
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.

See: http://www.codeproject.com/KB/system/change_drive_sn.aspx


Determine harddrive numbers: http://addressof.com/blog/archive/2004/02/13/386.aspx
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33624549
why dont u try a combination of id's
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 33624567
How To Get Hardware Information (CPU ID, MainBoard Info, Hard Disk Serial, System Information , ...)
http://www.codeproject.com/KB/system/GetHardwareInformation.aspx
0
 
LVL 1

Author Comment

by:XK8ER
ID: 33624573
Dhaest, saw that already and that's not really directly from hardware but from registry..
0
 
LVL 3

Expert Comment

by:xiong8086
ID: 33624714
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.
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 33624730
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 ?)
0
 
LVL 7

Expert Comment

by:Inteqam
ID: 33624888
How to Retrieve the REAL Hard Drive Serial Number

http://www.codeproject.com/KB/cs/hard_disk_serialno.aspx
0
 
LVL 1

Author Comment

by:XK8ER
ID: 33624911
yes but this is a VB.net section and question not C
0
 
LVL 1

Author Comment

by:XK8ER
ID: 33624915
and that C# also gets the hard drive serial from registry

ManagementObjectSearcher("SELECT * FROM Win32_PhysicalMedia")
0
 
LVL 7

Expert Comment

by:Inteqam
ID: 33624991
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 33624994
>> 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()
            hdCollection.Add(hd)
        Next

        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"
            Else
                hd.SerialNo = wmi_HD("SerialNumber").ToString()
            End If

            i += 1
        Next

        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)
            Console.WriteLine()
        Next

Open in new window

0
 
LVL 1

Author Comment

by:XK8ER
ID: 33624998
Inteqam, look at the section please..

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

0
 
LVL 7

Expert Comment

by:Inteqam
ID: 33625038
lol
i did, but if you have a clasic vb com or dll, you can easily use it in vb.net

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

 http://www.diskserialnumber.com/
0
 
LVL 1

Author Comment

by:XK8ER
ID: 33625057
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 vb.net instead?
0
 
LVL 53

Accepted Solution

by:
Dhaest earned 250 total points
ID: 33625065
Use a Visual Basic 6 DLL from VB .NET
http://www.vb-helper.com/howto_net_use_vb6_dll.html
0
 
LVL 7

Assisted Solution

by:Inteqam
Inteqam earned 250 total points
ID: 33625077
you need to move the class into a class library that compiles to a dll.

then you can reference the dll as a com into your vb.net
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB.NET 2008 - SQL Timeout 9 50
Create a datatable in vb.net dynamically 1 38
get combo value in class 5 23
Broken .resx file generating errors 18 15
Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question