Solved

Get Computer Unique ID

Posted on 1999-01-05
6
420 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…

749 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