Link to home
Start Free TrialLog in
Avatar of jimcooper1
jimcooper1

asked on

C Code to determine HDD serial number

Does anyone have a code snippet in C that retrieves a Hard Disk Drive serial number (manufacturers number not Volume Serial Number) Most graeful if you would share.
Avatar of evilrix
evilrix
Flag of United Kingdom of Great Britain and Northern Ireland image

Avatar of jimcooper1
jimcooper1

ASKER

Thanks, but I'm really looking for a C solution rather than C++
If you are using Windows, use GetVolumeInformation Win32 API
http://msdn.microsoft.com/en-us/library/aa364993(VS.85).aspx
http://support.microsoft.com/kb/139547

If you are using Linux, you will have to use some ioctls ... look into source code of hdparm
http://sourceforge.net/projects/hdparm/
Thanks, but I need the hardware serial number rather than the Volume serial number (and also need the C code rather than C++)
>> Thanks, but I'm really looking for a C solution rather than C++
Please take another look at the link I posted, it references a link to code that is C code (although there is some assembly as well).
http://www.winsim.com/diskid32/
evilrix,
thanks for the second post,  that diskid32.cpp does in fact seem to be C rather than C++.  That'll take quite a bit of unpicking for me..best I knuckle down and try to understand it.  Hopefully someone might have a simpler solution.
Regards
Jim
What platform?
>> evilrix, thanks for the second post
No worries.
What platform??

Win32 (XP and Vista)  possibly Win64 as well

Regards
ASKER CERTIFIED SOLUTION
Avatar of sunnycoder
sunnycoder
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for that .. although I am proficient at C, I am no Windows API programmer. I think I'll downgrade my self from intermediate to moron!!!