Solved

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

Posted on 1998-04-22
8
674 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
[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
  • 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
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

623 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