Which api can I used to get hard drive's serial number ?
Can anybody please help me.......
Printable View
Which api can I used to get hard drive's serial number ?
Can anybody please help me.......
Well I not on a windows machine at the second so I can't look at the Platform SDK. But I'm pretty sure you are looking for EnumDevices() or something like that.
Okay, ignore my ramblings :) That is completely wrong. I'm taking a look on msdn to see what is available.
Ah here we go:
Enjoy!Code:BOOL GetVolumeInformation(
LPCTSTR lpRootPathName,
LPTSTR lpVolumeNameBuffer,
DWORD nVolumeNameSize,
LPDWORD lpVolumeSerialNumber,
LPDWORD lpMaximumComponentLength,
LPDWORD lpFileSystemFlags,
LPTSTR lpFileSystemNameBuffer,
DWORD nFileSystemNameSize
);
code:----------------------------------------------------------------------------
BOOL GetVolumeInformation(
LPCTSTR lpRootPathName,
LPTSTR lpVolumeNameBuffer,
DWORD nVolumeNameSize,
LPDWORD lpVolumeSerialNumber,
LPDWORD lpMaximumComponentLength,
LPDWORD lpFileSystemFlags,
LPTSTR lpFileSystemNameBuffer,
DWORD nFileSystemNameSize
);
--------------------------------------------------------------------------------
But GetVolumeInformation() works for partitions just like C:, D:, and so on.....
Does it gives hard drive's serial number or partition's serial number ?
Judging by the 4th parameter of the function; yes, it does. You could try looking it up on MSDN.Quote:
Originally posted by cr_naik
code:----------------------------------------------------------------------------
BOOL GetVolumeInformation(
LPCTSTR lpRootPathName,
LPTSTR lpVolumeNameBuffer,
DWORD nVolumeNameSize,
LPDWORD lpVolumeSerialNumber,
LPDWORD lpMaximumComponentLength,
LPDWORD lpFileSystemFlags,
LPTSTR lpFileSystemNameBuffer,
DWORD nFileSystemNameSize
);
--------------------------------------------------------------------------------
But GetVolumeInformation() works for partitions just like C:, D:, and so on.....
Does it gives hard drive's serial number or partition's serial number ?