Home » Source Code » Searching for a reliable hardware ID

Searching for a reliable hardware ID

2015-02-25 01:18:42
The author
Download(s): 1
Point (s): 1 
Category Category:
Driver DevelopmentDriver Development CPlusPlus, C-C++C++


Translated by maninwest@Codeforge Author:Michael N Haephrati (האפרתי)@CodeProject
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). TheGetMACAddresscode 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.
Sponsored links

File list

Tips: You can preview the content of files by clicking file names^_^
Name Size Date
GetMacAddress_by_Michael_Haephrati.sln969.00 B2015-01-28|12:30
GetMacAddress_by_Michael_Haephrati\GetMacAddress_by_Michael_Haephrati.cpp2.77 kB2015-01-28|12:30
GetMacAddress_by_Michael_Haephrati\GetMacAddress_by_Michael_Haephrati.h673.00 B2015-01-28|12:30
GetMacAddress_by_Michael_Haephrati\GetMacAddress_by_Michael_Haephrati.rc11.32 kB2015-01-28|12:30
GetMacAddress_by_Michael_Haephrati\GetMacAddress_by_Michael_Haephrati.vcxproj6.41 kB2015-01-28|12:30
GetMacAddress_by_Michael_Haephrati\GetMacAddress_by_Michael_Haephrati.vcxproj.filters2.37 kB2015-01-28|12:30
GetMacAddress_by_Michael_Haephrati\GetMacAddress_by_Michael_Haephrati.vcxproj.user143.00 B2015-01-28|12:30
GetMacAddress_by_Michael_Haephrati\GetMacAddress_by_Michael_HaephratiDlg.cpp5.78 kB2015-01-28|12:30
GetMacAddress_by_Michael_Haephrati\GetMacAddress_by_Michael_HaephratiDlg.h816.00 B2015-01-28|12:30
GetMacAddress_by_Michael_Haephrati\HardDriveSerialNumer.cpp23.45 kB2015-01-28|12:30
GetMacAddress_by_Michael_Haephrati\HardDriveSerialNumer.h8.97 kB2015-01-28|12:30
GetMacAddress_by_Michael_Haephrati\ReadMe.txt5.05 kB2015-01-28|12:30
GetMacAddress_by_Michael_Haephrati\resource.h1.41 kB2015-01-28|12:30
GetMacAddress_by_Michael_Haephrati\stdafx.cpp236.00 B2015-01-28|12:30
GetMacAddress_by_Michael_Haephrati\stdafx.h1.76 kB2015-01-28|12:30
GetMacAddress_by_Michael_Haephrati\targetver.h314.00 B2015-01-28|12:30
GetMacAddress_by_Michael_Haephrati\res\GetMacAddress_by_Michael_Haephrati.ico66.19 kB2015-01-28|12:30
GetMacAddress_by_Michael_Haephrati\res\GetMacAddress_by_Michael_Haephrati.rc2852.00 B2015-01-28|12:30
Sponsored links


(Add your comment, get 0.1 Point)
Minimum:15 words, Maximum:160 words

Finding a reliable and unique Hardware ID is the toughest and boring task but if https://www.essaywritingland.com/college-essays/ is not properly done then a wrong ID can destroy your computer. One should try to produce a unique data element himself.

  • 1
  • Page 1
  • Total 1

Searching for a reliable hardware ID (78.04 kB)

Need 1 Point(s)
Your Point (s)

Your Point isn't enough.

Get 22 Point immediately by PayPal

Point will be added to your account automatically after the transaction.

More(Debit card / Credit card / PayPal Credit / Online Banking)

Submit your source codes. Get more Points


Don't have an account? Register now
Need any help?
Mail to: support@codeforge.com


CodeForge Chinese Version
CodeForge English Version

Where are you going?

^_^"Oops ...

Sorry!This guy is mysterious, its blog hasn't been opened, try another, please!

Warm tip!

CodeForge to FavoriteFavorite by Ctrl+D