Click here to Skip to main content
Click here to Skip to main content

Finger Print Class

By , 8 Jul 2007
 

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!

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)

About the Author

Johnny J.
Software Developer (Senior) JC Software Solutions
Sweden Sweden
Member
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 .NET developer building Airline Booking Systems, and have a number of projects in various states of progress to work on in the spare time...
 
PS: The cat on my profile is one of my three cats, Ramses. He's all white, odd-eyed, deaf and definitely the coolest cat there is!

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionA bug?memberJose 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.
 
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 5membermanoj kumar choubey22 Feb '12 - 21:44 
Nice
QuestionRestricting to single copy in all Virtual machines on multi-core 64-bit Physical machine?memberpaultraite28 Sep '10 - 9:30 
Taking a brief look at the source code, I was wondering if it handled the following:
 
1) CpuID() function --
a) This seems to really be Processor, not CPU? So a multi-core, but single-processor machine will always give the same value?
b) What about on a machine with 2 or more physical (possibly multi-core) processors?
c) Testing on a 64bit Windows 7 (home premium), seems to work. So, the Identifier("Win32_Processor", ...) reference works. Is there an umgrade to also search for ... "Win64_Processor", ... ?
 
2) For licensing purposes, I want to also prevent multiple copies of my software from running in separate Virtual machines on the same physical machine. Would each Virtual machine on the same physical machine return the same value?
 
In a non-virtualized world, I can prevent multiple simultanious copies by, for example, writing and re-checking my processID to a shared resource -- if it changes out from under a running process, there's a extra copy active. But, across a set of Virtualized machines, there are no shared resources (ex. filesystem, memory).
QuestionCould you explain the logic of this?memberAsher Barak6 Nov '08 - 9:03 
I am trying to get a unique finger print of a PC (to develop a licensing server). For as much a I could find to read, there could be more than one MAC, (definetly) more than one HD (and they might change), not all CPU's have an ID etc'.
Now, how does mixing a few of these make thing setter? It seems the finger print would change more frequently if you add more factors?
 
Could you explain the logic? Confused | :confused:
 
Asher
GeneralProblem running as different usersmemberandrescasta22 May '08 - 10:26 
Hello, this code is really good, but i´m having a problem when i ran it from different Windows XP User Accounts,
 
The problem is thar it return differents FingerPrint numbers in the same computer when i ran it from different users account (Administrator, Power User, User).
 
Example:
 
Administrator:29664280
PUser (Member of Power Users) :28164760
BUser (Member of Users):28158580
 
Thank's in advance.
 
Andres.
 
modified on Thursday, May 22, 2008 4:32 PM

GeneralC# articlememberc_srishti8 Apr '08 - 13:31 
Hello Johnny,
Do you have a link to the original article in c# by brian?
Can you plese post that here if you have it?
Thanks a lot
Srishti
GeneralRe: C# articlememberJohnny J.8 Apr '08 - 21:36 
I'm afraid I haven't got that, but I'll tell you what:
 
If you check the comments below, you will find some comments by Brian. If you post your question as a reply to one of those, he should get an email about it (if he has signed up for email notifications), and he might have it himself.
 
If you get it, could either you or Brian please post it here??? - then I'll include it in the text...
 
Cheers,
Johnny
GeneralRe: C# articlememberJohnny J.17 Sep '10 - 2:59 
I found this accidentally, but I don't recall if that was the original post I modified. But it could be...
 
http://www.vbforums.com/showthread.php?t=250436[^]
Generalcann't downloadmemberEng_MR4 Jan '08 - 22:49 
how i can download source code
i do it but link is incorrect
thanks
 
Eng.Mohammed Ramadan Al-Ashry

GeneralRe: cann't downloadmemberJohnny J.4 Jan '08 - 23:06 
I'm sorry, but I don't know. I have just tried all of the download links in the article, and it works fine for me...?!?!?!
 
You could try to check with the CodeProject admin... That's my best idea.
 
Cheers,
Johnny J.

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

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 9 Jul 2007
Article Copyright 2007 by Johnny J.
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid