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

Tagged as

Searching for a reliable hardware ID

, 28 Jan 2015 CPOL
Rate this:
Please Sign up or sign in to vote.
How a computer can be identified in order to generate a unique ID.


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 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 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.

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.


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


About the Author

Michael N Haephrati (האפרתי)
CEO Secured Globe, Inc.
United States United States
Michael Haephrati, is an entrepreneur, inventor and a musician. Haephrati 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. Worked at a research institute made the fist steps developing the credit scoring field in Israel. He founded Target Scoring and developed a credit scoring system named ThiS, 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).

During 2000, he founded Target Eye, and developed the first remote PC surveillance and monitoring system, named Target Eye.

Other ventures included: Data Cleansing (as part of the DataTune system which was implemented in many organizations.

Follow on   Twitter   Google+   LinkedIn

Comments and Discussions

Questionadditional thoughts PinmemberGernot Frisch2-Feb-15 6:32 
AnswerRe: additional thoughts PinprofessionalMichael N Haephrati (האפרתי)3-Feb-15 11:37 
QuestionUnique Machine ID pretty much impossible PinmemberMike Nordell1-Feb-15 13:05 
AnswerRe: Unique Machine ID pretty much impossible PinprofessionalMichael N Haephrati (האפרתי)3-Feb-15 11:38 
GeneralRe: Unique Machine ID pretty much impossible PinmemberMike Nordell7-Feb-15 16:11 
QuestionWMI? Pinmemberdandy7228-Jan-15 13:14 
SuggestionIt's risky to be depend on only one id PinmemberCracked-Down28-Jan-15 8:12 
GeneralRe: It's risky to be depend on only one id PinprofessionalMichael N Haephrati (האפרתי)28-Jan-15 8:22 
GeneralMy vote of 5 PinmemberJunfengGuo7-Jul-14 16:16 
SuggestionMessage Automatically Removed Pinmemberkamleshgs15-May-14 7:56 
GeneralMy vote of 5 Pinmemberwangluozhanglei18-Sep-13 0:53 
GeneralMy vote of 5 PinmemberMember 1023960228-Aug-13 23:24 
GeneralMy vote of 5 PinmemberOded Sagi15-Aug-13 5:22 
GeneralMy vote of 5 Pinmemberalonamir12-Aug-13 23:00 
GeneralMy vote of 4 Pinprofessionallyyong9-Jul-13 16:25 
GeneralRe: My vote of 4 PinmvpMichael Haephrati9-Jul-13 21:06 
GeneralMy vote of 5 Pingroupalonbarak14-Jun-13 12:11 
QuestionCurrent drive insteat of main drive PinmemberKarsten Gutjahr4-Mar-13 3:30 
AnswerRe: Current drive insteat of main drive PinmvpMichael Haephrati4-Mar-13 4:06 
GeneralMy vote of 5 PinmemberBigMax26-Feb-13 8:35 
GeneralMy vote of 5 PinmemberMike Meinz21-Feb-13 11:31 
GeneralMy vote of 5 PinmemberMember 416352421-Feb-13 6:37 
SuggestionSuggestion PinmvpMichael Haephrati20-Feb-13 13:18 
GeneralRe: Suggestion [modified] PinmemberEmilio Garavaglia20-Feb-13 22:15 
GeneralRe: Suggestion PinmvpMichael Haephrati20-Feb-13 23:29 
GeneralRe: Suggestion PinmemberEmilio Garavaglia20-Feb-13 23:49 
GeneralRe: Suggestion PinmvpMichael Haephrati21-Feb-13 0:34 
GeneralMy vote of 1 PinmemberEmilio Garavaglia20-Feb-13 12:31 
GeneralRe: My vote of 1 PinmvpMichael Haephrati20-Feb-13 13:00 
SuggestionLicensing issues PinmvpMichael Haephrati מיכאל האפרתי20-Feb-13 8:03 
GeneralMy vote of 2 PinmemberGrump28-Jan-13 8:33 
GeneralMy vote of 5 Pinmemberliliflower35525-Jan-13 2:21 
GeneralMy vote of 5 Pinmemberresi243125-Jan-13 1:17 
GeneralMy vote of 5 Pinmembermidulm25-Jan-13 0:11 
Great Article !!!
GeneralMy vote of 5 Pingroupbalam198824-Jan-13 23:25 
GeneralMy vote of 5 Pingroupevan89724-Jan-13 22:47 
GeneralMy vote of 5 PinmemberJohn Klinner24-Jan-13 21:36 
GeneralMy vote of 5 PinmemberRutuanie24-Jan-13 20:28 
GeneralMessage Automatically Removed PinmemberPJohnMathews23-Jan-13 23:22 
GeneralMy vote of 1 PinmemberPJohnMathews23-Jan-13 20:58 
GeneralMy vote of 5 PinmemberRumon200014-Oct-12 4:02 
GeneralMy vote of 5 PinmemberHillary Higg14-Oct-12 0:01 
GeneralMy vote of 5 PinmemberAnita Berg13-Oct-12 12:19 
GeneralMy vote of 5 Pinmemberjohannafeldman1213-Oct-12 12:07 
GeneralMy vote of 5 PinmemberGeorge Rogers II13-Oct-12 7:42 
GeneralMy vote of 5 PinmemberEmma20123217-Sep-12 7:47 
GeneralMy vote of 5 PinmemberHillary Higg17-Sep-12 4:33 
QuestionHD serial number is not reliable Pinmemberatali12-Mar-12 13:13 
AnswerRe: HD serial number is not reliable Pinmemberzoomgod11-May-12 17:48 
GeneralRe: HD serial number is not reliable PinmvpMichael Haephrati מיכאל האפרתי19-Feb-13 7:50 

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.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150414.1 | Last Updated 28 Jan 2015
Article Copyright 2012 by Michael N Haephrati (האפרתי)
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid