Click here to Skip to main content
15,299,263 members
Articles / Programming Languages / C++
Posted 24 Jan 2012


210 bookmarked

Searching for a Reliable Hardware ID

Rate me:
Please Sign up or sign in to vote.
4.93/5 (106 votes)
26 Mar 2020CPOL3 min read
How a computer can be identified in order to generate a unique ID
Many desktop application developers need to uniquely identify the computer on which their software is running. This article will show you how it can be done.


Many desktop application developers need to uniquely identify the computer on which their software is running. 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.  Note: there is also an excellent article focusing on the BIOS UUID. The article was written by .

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 III, 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 for each machine.

Image 1

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.

I would like to add that the serial number to be used, must be the one set by the manufacturer as opposed to the one set (and which can be changed) by the Operating System.


  • 28th January, 2015: Initial version


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 Secured Globe, Inc.
United States United States
Michael Haephrati, Musician and CEO and co-founder of Secured Globe, Inc. Worked on many ventures starting from HarmonySoft, designing Rashumon, the first Graphical Multi-lingual word processor for Amiga computer. During 1995-1996 he worked as a Contractor with Apple at Cupertino.

You can also Buy me coffee.

Comments and Discussions

SuggestionLicensing issues Pin
Michael Haephrati20-Feb-13 7:03
mvaMichael Haephrati20-Feb-13 7:03 
GeneralMy vote of 2 Pin
Grump28-Jan-13 7:33
MemberGrump28-Jan-13 7:33 
GeneralMy vote of 5 Pin
liliflower35525-Jan-13 1:21
Memberliliflower35525-Jan-13 1:21 
GeneralMy vote of 5 Pin
resi243125-Jan-13 0:17
Memberresi243125-Jan-13 0:17 
GeneralMy vote of 5 Pin
midulm24-Jan-13 23:11
Membermidulm24-Jan-13 23:11 
GeneralMy vote of 5 Pin
balam198824-Jan-13 22:25
Memberbalam198824-Jan-13 22:25 
GeneralMy vote of 5 Pin
evan89724-Jan-13 21:47
Memberevan89724-Jan-13 21:47 
GeneralMy vote of 5 Pin
John Klinner24-Jan-13 20:36
MemberJohn Klinner24-Jan-13 20:36 
GeneralMy vote of 5 Pin
Ruth Aanie24-Jan-13 19:28
MemberRuth Aanie24-Jan-13 19:28 
GeneralMy vote of 1 Pin
PJohnMathews23-Jan-13 19:58
MemberPJohnMathews23-Jan-13 19:58 
GeneralMy vote of 5 Pin
Rumon200014-Oct-12 3:02
MemberRumon200014-Oct-12 3:02 
GeneralMy vote of 5 Pin
Hillary Higg13-Oct-12 23:01
MemberHillary Higg13-Oct-12 23:01 
GeneralMy vote of 5 Pin
Anita Berg13-Oct-12 11:19
MemberAnita Berg13-Oct-12 11:19 
GeneralMy vote of 5 Pin
johannafeldman1213-Oct-12 11:07
Memberjohannafeldman1213-Oct-12 11:07 
GeneralMy vote of 5 Pin
George Rogers II13-Oct-12 6:42
MemberGeorge Rogers II13-Oct-12 6:42 
GeneralMy vote of 5 Pin
Emma20123217-Sep-12 6:47
MemberEmma20123217-Sep-12 6:47 
AnswerRe: My vote of 5 Pin
Michael Haephrati21-Sep-17 10:28
mvaMichael Haephrati21-Sep-17 10:28 
GeneralMy vote of 5 Pin
Hillary Higg17-Sep-12 3:33
MemberHillary Higg17-Sep-12 3:33 
AnswerRe: My vote of 5 Pin
Michael Haephrati21-Sep-17 8:58
mvaMichael Haephrati21-Sep-17 8:58 
QuestionHD serial number is not reliable Pin
atali12-Mar-12 12:13
Memberatali12-Mar-12 12:13 
AnswerRe: HD serial number is not reliable Pin
dogmooz11-May-12 16:48
Memberdogmooz11-May-12 16:48 
GeneralRe: HD serial number is not reliable Pin
Michael Haephrati19-Feb-13 6:50
mvaMichael Haephrati19-Feb-13 6:50 
GeneralMy vote of 4 Pin
Steve Mann5-Mar-12 13:18
MemberSteve Mann5-Mar-12 13:18 
SuggestionHow I solved these various problems. Pin
Steve Mann5-Mar-12 13:17
MemberSteve Mann5-Mar-12 13:17 
AnswerRe: How I solved these various problems. Pin
Michael Haephrati19-Feb-13 6:48
mvaMichael Haephrati19-Feb-13 6:48 

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.