?
Solved

Get Computer Unique ID

Posted on 1999-01-05
6
Medium Priority
?
444 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

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 200 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

800 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