Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++
I have been hunting for c++ hard disk retrieval code for some time now, but all the ones I have seen never worked. Please who can anyone tell me where I can get a tested and trusted hard disk retrieval code.
Posted 10-May-11 12:20pm
Gbenbam988
Comments
Hans Dietrich at 10-May-11 20:46pm
   
I'm not sure what you mean by "trusted", but be aware that there are utilities freely available that can be used to change the HD serial number. So while you can get the current serial number, don't think it can't change.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

If you just want the serial number for the logical parition, you can use this API: GetVolumeInformation.
 
For the serial id of the physical disk, most people use WMI. There's a CP article that shows how to do this without WMI:
 
Get Physical HDD Serial Number without WMI[^]
 
Make sure you read the comments on that article's forum - it may require admin rights on Vista/Windows 7.
  Permalink  
v2
Comments
Espen Harlinn at 20-May-11 13:13pm
   
Good reply :)
Sandeep Mewara at 25-May-12 7:14am
   
Comment from some other member posted as a solution: FeedBack for Solution 1:

Hard Disk serial number differ from Volume Serial Number.. You need to do hardware level coding to retrieve that...
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

if you only need the serial number of the drive this will do the job. But caution: it is the number Windows gives it while the formatting process. It is NOT the number of the HD manufacturer.
 
DWORD serialNumber = -1;
 
if( ::GetVolumeInformation(lpDrive, NULL, NULL, &serialNumber, NULL, NULL, NULL, NULL ) )
{
TRACE(_T("Serial Number: %lu of drive %s\n"), serialNumber, lpDrive);
}
else
{
ASSERT(FALSE);
}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 6 May 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100