Solved

How to read Hard Disk Serial No. ( Volume No.) in C++ program ?

Posted on 1998-04-22
8
665 Views
Last Modified: 2008-02-01
Hi,
I want to implement a functionality in my C/C++ program to read the hard disk serial no. ( Volume no. ) on which it is installed. Every time it runs , i want to check the serial no. to validate it...Can somebody suggest me a way for doing this ??
If someone can give me the function which does that i would really appreciate!!! Or suggest me the elegant way of achieving the same...
Hope to hear soon....
Nikhil
0
Comment
Question by:nikhil_vora
  • 5
  • 2
8 Comments
 
LVL 22

Accepted Solution

by:
nietod earned 200 total points
ID: 1163226
ANSWER COMING.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1163227
Use the GetVolumeInformation() Windows API procedure.  With this procedure you specify a path to the root directory of the volumne you are interested in, like "C:\\"  (two backslashes specified to put one in the string).  The procedure returns a bunch of different pieces of information one of which is the serial number.  

Let me know if you need more.
0
 

Author Comment

by:nikhil_vora
ID: 1163228
Hi,
This gives me the volume no. of drive of the hard disk, here what happens is that if i hv 3 drives on my hard disk named c,d,e i will hv 3 different volume no. for same hard disk, can i hv the serial no. of the hard disk itself ??
Also, what i am not sure is that whether this serial no.s on the drive are unique or not ??? I think ,  i can hv duplicate volume serial no. ( correct me if i am wrong )!!!!
THanks
0
 
LVL 22

Expert Comment

by:nietod
ID: 1163229
I have no earthly idea.  I can test it though.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 22

Expert Comment

by:nietod
ID: 1163230
Apparently this functon returns the "volume serial number" which is not the same as the "hard disk serial number".  If you have a single disk that is partitioned into two or more volumes, each volume has its own volume serial number.  Is that a problem?
0
 
LVL 11

Expert Comment

by:alexo
ID: 1163231
Volume serial numbers are not guaranteed to be unique.  They are pseudo-random numbers that have a GOOD CHANCE of being unique, not more than that.
If you want something that is guaranteed to be unique, use the network card's MAC number.  Problem is, the computer might not have a network card...
0
 
LVL 22

Expert Comment

by:nietod
ID: 1163232
If I had to guess (and I do have to guess) this is probably for a software copy protection system.  If so, the volumne serial numbers are unique enough.  It means that the users would be able to copy the software and make it run on another computer that has the same volumne number.  But the odds of two volumes having the same number are 1 in 4 billion.  That seems adequate.  
0
 

Author Comment

by:nikhil_vora
ID: 1163233
Hi,
Does anybody know abt. any other unique identity on PC which i can use instead of hard disk volume no. ? I think i can use bios check sum for this validation also ? Can anybody suggest me something ?
I don't want to use MAC serial no. as the PC may not be having it. But i think getting bios info. should be ok, can somebody throw some light on how to get it ?? Also, if anybody has some good suggestion abt. the scheme , please let me know.
Thanks
-Nikhil

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

930 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

15 Experts available now in Live!

Get 1:1 Help Now