Solved

Get Computer Unique ID

Posted on 1999-01-05
6
410 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

815 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

11 Experts available now in Live!

Get 1:1 Help Now