Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 1998-04-22
8
Medium Priority
?
697 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 400 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 22

Expert Comment

by:nietod
ID: 1163229
I have no earthly idea.  I can test it though.
0
 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

916 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