Click here to Skip to main content
15,860,972 members
Articles / Programming Languages / Visual Basic

Finger Print Class

Rate me:
Please Sign up or sign in to vote.
3.43/5 (22 votes)
8 Jul 2007CPOL2 min read 133K   6.7K   88   27
Get a unique Finger Print / Machine ID which can be used for licensing purposes.

Screenshot - FingerPrint.gif

Introduction

For my current project, I was looking for some way to generate a unique machine ID from the running computer's hardware so that I could use it for license purposes.

I looked everywhere, but I couldn't find any information as to how to do that. I did find a couple of third party controls that looked OK. One of them was TheScarms AppSentinel component (http://www.thescarms.com/AppSentinel/default.aspx), but unfortunately, that was written in VB6, and required distributing the VB6 runtime files. I didn't want to do that. The other was Ionworx' Machine ID component (http://www.ionworx.com/machineid.html). That looked OK, so I purchased the control. But, due to a lot of complications, I didn't get the license key from Ionworx until two weeks later.

Now, what does a person do in the meantime? I continued looking around the net, but with little luck. Until I happened to stumble over a page in another forum. A guy named Brian Hawley had done an absolutely brilliant piece of code. It was precisely what I was looking for - and simply too good to pass up.

I cannot take credit for the idea itself - all credit goes to Brian. But, I did convert the code from C#.NET to VB.NET (2005 - Framework 2.0), and I added some extra functionality. I hope Brian doesn't mind, because the code is simply too good not to share with others.

What the code does is that it gets the ID from the computer's CPU, BIOS, hard disk, motherboard, video card, and network adapter. It mixes it all together and generates an ID.

I added the possibility of selecting exactly what parts should be included in the test. You can use all, but I strongly recommend skipping the CPU ID, because it takes a really long time.

I also added the possibility of selecting the number of characters the result should consist of. More than 8 is really not necessary, because the number normally doesn't get any longer than that, but you might want to write your own routine to utilize the data and generate the machine ID from some other algorithm.

Background

If you're interested, the original C# code is here (6.64 KB), and a C# demo program can be found here (18.2 KB).

The direct translation to VB.NET done by me can be found here (13.7 KB). It is identical to the C# code above.

And of course, the enhanced code and VB demo programs can be downloaded from the links at the top.

Using the code

You simply need to instantiate the class and set the required properties. Then, you query the Value property - et voila!

VB
Private fp As JCS.FingerPrint = New JCS.FingerPrint

fp.UseCpuID = False
fp.UseBiosID = True
fp.UseBaseID = True
fp.UseDiskID = True
fp.UseVideoID = True
fp.UseMacID = True

fp.ReturnLength = 8

MsgBox("Finger Print is: " & fp.Value)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Sweden Sweden
Born in Copenhagen, Denmark
Have been living in Paris, France and L.A., The United States
Now live in Stockholm, Sweden

Started programming when I got my first VIC 20, and a few months later on Commodore 64. Those were the days!

Studied programming at the Copenhagen Engineering Academy

Professional console, winforms and webforms programming in Comal, x86 Assembler, Fortran, Pascal, Delphi, Visual Basic 3 through 6, Classic ASP, C# and VB.NET

I now work as Senior Microsoft Dynamics AX and .Net programmer, and have a number of projects in various states of progress to work on in the spare time...

Comments and Discussions

 
GeneralUPDATE 2019 - not working for windows 8 & 10 Pin
Tom Zürich14-Jul-19 1:23
Tom Zürich14-Jul-19 1:23 
QuestionA bug? Pin
Jose A Pascoa2-Feb-13 2:11
Jose A Pascoa2-Feb-13 2:11 
I know this article is old, probably you don't even remember it but I think I found an issue.

In the function below can you tell me in what case RetVal += Identifier("Win32_Processor", "MaxClockSpeed") is supposed to be executed? I think you want to run it every time but it does not.

VB
Private Function CpuID() As String
     RaiseEvent StartingWith("CpuID")

     'Uses first CPU identifier available in order of preference
     'Don't get all identifiers as very time consuming
     Dim RetVal As String = Identifier("Win32_Processor", "UniqueId")

     If RetVal = "" Then   'If no UniqueId, use ProcessorID
         RetVal = Identifier("Win32_Processor", "ProcessorId")

         If RetVal = "" Then   'If no ProcessorID, use Name
             RetVal = Identifier("Win32_Processor", "Name")

             If RetVal = "" Then   'If no Name, use Manufacturer
                 RetVal = Identifier("Win32_Processor", "Manufacturer")
             End If

             'Add clock speed for extra security
             RetVal += Identifier("Win32_Processor", "MaxClockSpeed")
         End If
     End If

     Return RetVal

     RaiseEvent DoneWith("CpuID")
 End Function


Regards,

Jose
GeneralMy vote of 5 Pin
Manoj Kumar Choubey22-Feb-12 21:44
professionalManoj Kumar Choubey22-Feb-12 21:44 
QuestionRestricting to single copy in all Virtual machines on multi-core 64-bit Physical machine? Pin
paultraite28-Sep-10 9:30
paultraite28-Sep-10 9:30 
QuestionCould you explain the logic of this? Pin
Asher Barak6-Nov-08 9:03
professionalAsher Barak6-Nov-08 9:03 
GeneralProblem running as different users Pin
andrescasta22-May-08 10:26
andrescasta22-May-08 10:26 
GeneralC# article Pin
c_srishti8-Apr-08 13:31
c_srishti8-Apr-08 13:31 
GeneralRe: C# article Pin
Johnny J.8-Apr-08 21:36
professionalJohnny J.8-Apr-08 21:36 
GeneralRe: C# article Pin
Johnny J.17-Sep-10 2:59
professionalJohnny J.17-Sep-10 2:59 
Generalcann't download Pin
Eng_MR4-Jan-08 22:49
Eng_MR4-Jan-08 22:49 
GeneralRe: cann't download Pin
Johnny J.4-Jan-08 23:06
professionalJohnny J.4-Jan-08 23:06 
GeneralRe: cann't download [modified] Pin
Eng_MR5-Jan-08 0:25
Eng_MR5-Jan-08 0:25 
QuestionHow can i make your demo work? Pin
Umega13-Nov-07 21:32
Umega13-Nov-07 21:32 
AnswerRe: How can i make your demo work? Pin
Johnny J.13-Nov-07 21:54
professionalJohnny J.13-Nov-07 21:54 
GeneralRe: How can i make your demo work? Pin
Umega14-Nov-07 13:53
Umega14-Nov-07 13:53 
GeneralThanks. Pin
brian.hawley28-Jun-07 3:35
brian.hawley28-Jun-07 3:35 
GeneralRe: Thanks. Pin
Johnny J.28-Jun-07 3:54
professionalJohnny J.28-Jun-07 3:54 
GeneralRe: Thanks. Pin
brian.hawley28-Jun-07 3:59
brian.hawley28-Jun-07 3:59 
GeneralVB6 Fingerprint Pin
EdwardX216-Jun-07 4:50
EdwardX216-Jun-07 4:50 
GeneralRe: VB6 Fingerprint Pin
Johnny J.16-Jun-07 13:04
professionalJohnny J.16-Jun-07 13:04 
GeneralRe: VB6 Fingerprint Pin
pikoon14-Mar-08 22:40
pikoon14-Mar-08 22:40 
GeneralRe: VB6 Fingerprint Pin
EdwardX217-Jun-07 13:03
EdwardX217-Jun-07 13:03 
GeneralRe: VB6 Fingerprint Pin
Johnny J.26-Jun-07 21:39
professionalJohnny J.26-Jun-07 21:39 
GeneralRe: VB6 Fingerprint Pin
Ionworx7-Jul-07 13:53
Ionworx7-Jul-07 13:53 
GeneralRe: VB6 Fingerprint Pin
Johnny J.8-Jul-07 21:03
professionalJohnny J.8-Jul-07 21:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.