Solved

Get Computer Unique ID

Posted on 1999-01-05
6
396 Views
Last Modified: 2013-12-03
I need code to obtain a computer specific information, HDD serial number, BIOS date and so on.
0
Comment
Question by:VAM345
6 Comments
 
LVL 11

Expert Comment

by:alexo
ID: 1418077
This question pops about once or twice a month on EE.

If you want to do it for copy protection -- don't!  Two reasons:

1. This kind of copy protection is easy to break.

2. If a legitimate user upgrades his hardware and your program stops working, you'll get no return business and lots of bad publicity.

[I'm submitting this as a comment so you can delete the question]
0
 

Expert Comment

by:PeteI
ID: 1418078
With the exception of network cards, there's no PC hardware that's guaranteed to have a unique ID.

There are some quasi-unique values that are relatively easy to obtain.  For instance, you can get a volume serial number (a DWORD based on the date and time the volume was formatted) by calling GetVolumeInformation().

One reasonable was to uniquely identify a PC is to create a GUID (CoCreateGuid) and stash it on the system -- the registry is a good place.  The chance of two GUIDs matching is astronomically remote.


0
 
LVL 1

Author Comment

by:VAM345
ID: 1418079
Volume serial number is easy to fake.
With GUID can`t sure to that is same computer. With out LAN card GUID is not similar digit, obtain thah is same machine.
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Expert Comment

by:PeteI
ID: 1418080
VAM345, Your comment is difficult to understand.

Note that I didn't specify that the volume serial number is guaranteed unique.  It's not.  It is, however, a well-distributed value that is _unlikely_ to change over time.

A GUID is a Globally Unique Identifier.  That means a GUID created on one machine via CoCreateGuid() will never match a GUID created on any other machine ever again, regardless of whether or not the machine has a network card.
0
 
LVL 1

Author Comment

by:VAM345
ID: 1418081
Problem is I need to obtain ID every time when I start program ant check that is same mashine.
0
 

Accepted Solution

by:
ddgamer earned 100 total points
ID: 1418082
I do not understand why you say the GetVolumeInformation() will not work.

It doesn't return a GUID, but lpdwVolSerialNum, or a pointer to a Dword.

So it seems that this number should be the same unless the user re-formats the drive.

--------------------------------------------------
The c code to do this is as follows:

// Your variables
static char szVolLabel[128];
static char szRootPath[MAX_PATH+1];
DWORD  dwVolSerialNum = 0;

//Make root path information
GetCurrentDirectory( MAX_PATH, szRootPath);
szRootPath[3] = 0;


//Get the Volume Information
GetVolumeInformation( szRootPath, szVolLabel, sizeof(szVolLabel)-1, &dwVolSerialNum, NULL, NULL, NULL, 0);

--------------------------------------------------

That should do it.

However, if what you are looking for is a truly low level solution to this in Windows then you are out of luck, unless you feel like doing some really complex Vxd programming. The serial number returned by GetVolumeInformation is the only place that I know of to get the serial number without performing direct disk access. Which can not be done unless you are in a VxD or can obtain ring0 access in your application somehow.

If any of this just gives you more questions write to me at ddgamer@hotmail.com. I'll try to help you out if I can.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now