Solved

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

Posted on 1998-04-22
8
663 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

758 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

22 Experts available now in Live!

Get 1:1 Help Now