Click here to Skip to main content
Licence CPOL
First Posted 24 Jan 2012
Views 16,914
Downloads 2,193
Bookmarked 52 times

Searching for a reliable hardware ID

By | 29 Feb 2012 | Article
How a computer can be identified in order to generate a unique ID.

Introduction

Many desktop application developers need to uniquely identify the computer in which their software is running on. Such identification must produce a unique data element which will be different per each computer and will reproduce the same ID on any given computer.

The WMI set of classes

Windows provides a set of classes that can be used for most hardware enumeration and identification tasks, which is named WMI or Windows Management Instrumentation. These are extensions to the Windows Driver Model (WDM).

WMI provides per instrumented component static information and dynamic notification about any changes. Most programming languages can be used to manage, locally and remotely, computers and servers, enumerating their instrumented components and alerted for changes that occur.

During my research, I came to the conclusion that if speed and reliability is important, it is better to access hardware via the Win32 API and not use WMI. I have experienced many delays and in some occasions, WMI failed to detect an element such as the CPU ID.

This article focuses on the direct approach for obtaining this data without using WMI.

Obtaining a unique CPU ID

The solution that seems to be the best choice is to sample the CPU unique identification number (or CPU ID). However, there are several problems that makes it impossible to rely on reading the CPU ID.

To begin with, most CPUs with the exception of the old Pentium 3, don't have a unique CPU Serial Number. Intel has removed this feature for privacy reasons.

It is still possible to generate a unique ID from the motherboard as a whole. That certainly works but the huge number of different types of motherboards and manufacturers makes it next to impossible to generate a unique ID that will cover all of them.

In fact, a French company named CPU ID, focuses in this field and spends a lot of resources in getting to learn each type of motherboard and CPU, in order to cover them all.

The following screenshot shows the details that can be collected per each machine.

Their SDK can be downloaded here, and can be used both as a static library (per special request) or a DLL with any application developed. The bad news is that even the guys from CPUID say it is impossible to generate a unique hardware ID based on the CPU or the motherboard of a given machine.

MAC address based hardware ID

The next choice for obtaining such a unique ID would be sampling the MAC address. To begin with, what is the "MAC address"? It stands for Media Access Control. The MAC address is 48 bits long (6 bytes). The GetMACAddress code sample explains how to obtain the MAC address.

However, there is one problem with this approach: the MAC address can be easily changed into a new one...

Hard Drive serial number

It seems that the only reliable solution for obtaining a machine ID would be using the serial number of the main Hard Drive. The second example, GetHDSerialNumber, shows how to obtain this ID. From my experience, this approach is the best one and the most reliable for generating a unique machine based hardware ID.

License

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

About the Author

Michael Haephrati

CEO
Michael Haephrati
Israel Israel

Member

Follow on Twitter Follow on Twitter
An inventor and an expert specilizes in software development and information security, who has built a unique perspective which combines technology and the end user experience.
 
Mr. Haephrati has founded Target Eye on 2000. The Target Eye Monitoring software was developed since then. Before inventing Target Eye, worked on many ventures starting from HarmonySoft, designing the first Graphical Multi-lingual word processor for Amiga computer. Other ventures included: Data Cleansing (as part of the DataTune system which was implemented in:the Standards Institute of Israel, The Israeli Export Institute, Bezeq Call, Microsoft Israel, Del Technologies and Elite), developed GIS systems, Credit Scoring computerized systems. Managed a great number of software and IS projects for: Telecom, New Zealand (1994-1995), Apple, Silicon Valley (1995-1996), Israeli Police, OCR for traffic tickets pilot and license plate number identification for road cameras (1995, as part of TIS, Project Manager). During 1998-2000 has developed a credit scoring system based on geographical statistical data, participating VISA CAL, Isracard, Bank Leumi and Bank Discount (Target Scoring, being the VP Business Development of a large Israeli institute).
 
Member of the London Institute of Directors (since 2001)
Member of the International Association of Financial Crimes Investigators (since 1998).
Member of IACTI – THE INTERNATIONAL ASSOCIATION OF COUNTERTERRORISM INVESTIGATORS. (since 2000).

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. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionHD serial number is not reliable Pinmemberatali12:13 12 Mar '12  
AnswerRe: HD serial number is not reliable Pinmemberzoomgod16:48 11 May '12  
GeneralMy vote of 4 PinmemberSteve Mann13:18 5 Mar '12  
SuggestionHow I solved these various problems. PinmemberSteve Mann13:17 5 Mar '12  
GeneralMy vote of 5 Pinmember@k@ ?9:22 5 Mar '12  
Suggestion[My vote of 1] thief, stolen code from diskid32 Pinmemberredcheek16:10 13 Feb '12  
GeneralRe: [My vote of 1] thief, stolen code from diskid32 PinmemberMichael Haephrati18:34 13 Feb '12  
GeneralRe: [My vote of 1] thief, stolen code from diskid32 PinmemberLeslieM12:48 15 Feb '12  
Questioncpu, nic's, & mac's; oh my! PinmemberGreg Cadmes10:31 31 Jan '12  
AnswerRe: cpu, nic's, & mac's; oh my! PinmemberMichael Haephrati11:23 31 Jan '12  
GeneralRe: cpu, nic's, & mac's; oh my! PinmemberGreg Cadmes11:30 31 Jan '12  
AnswerRe: cpu, nic's, & mac's; oh my! PinmemberLeslieM12:31 15 Feb '12  
AnswerRe: cpu, nic's, & mac's; oh my! PinmemberDavide Zaccanti19:50 1 Mar '12  
GeneralMy vote of 5 PinmemberJeff Kibling3:29 31 Jan '12  
SuggestionAnd now for something completely different PinPopularmemberNico Cuppen22:32 30 Jan '12  
GeneralRe: And now for something completely different PinmemberMichael Haephrati9:42 1 Feb '12  
GeneralRe: And now for something completely different PinmemberNico Cuppen10:11 1 Feb '12  
GeneralRe: And now for something completely different PinmemberMichael Haephrati10:21 1 Feb '12  
QuestionID for software protection PinmemberGernot Frisch21:08 30 Jan '12  
AnswerRe: ID for software protection PinmemberMichael Haephrati21:18 30 Jan '12  
GeneralRe: ID for software protection PinmemberGernot Frisch22:31 30 Jan '12  
QuestionVirtual machine? PinmemberJens Kastensson20:32 30 Jan '12  
AnswerRe: Virtual machine? PinmemberMichael Haephrati21:14 30 Jan '12  
AnswerRe: Virtual machine? PinmemberNiels Peter Gibe2:55 5 Mar '12  
QuestionJust a 5 cents to the topic PinmemberDmitry Zubrilin18:59 30 Jan '12  

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

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

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 29 Feb 2012
Article Copyright 2012 by Michael Haephrati
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid