Re: hard disk serial number

[ DelphiLand FAQ ]

Posted by webmaster Guido on March 26, 2004 at 17:57:40:

In Reply to: Re: retrieve computer serial number posted by Joey on March 25, 2004 at 22:17:55:

: Wouldnt a hard drives serial number be always different?? If so then you could just use dat ;)

: function GetHardDiskSerial(const DriveLetter: Char): string;
: var
: NotUsed: DWORD;
: VolumeFlags: DWORD;
: VolumeInfo: array[0..MAX_PATH] of Char;
: VolumeSerialNumber: DWORD;
: begin
: GetVolumeInformation(PChar(DriveLetter + ':\'),
: nil, SizeOf(VolumeInfo), @VolumeSerialNumber, NotUsed,
: VolumeFlags, nil, 0);
: Result := Format('Label = %s VolSer = %8.8X',
: [VolumeInfo, VolumeSerialNumber])
: end;

: das a function to get it... but im not quite sure if it will be unique on every harddrive... if im just bein dum dum say ;) heehee

Almost correct ;)
GetVolumeInformation does not get the hard disk serial number, but the "volume serial number".

The volume serial number is assigned during the formatting of the disk volume. Some companies use cloning tools for installing software onto new computers, so the volume serial numbers for these disks are identical.

For IDE hard disks, you can get the real manufacturer's serial number, model name,
firmware revision, and other IDE hard disk information using the S.M.A.R.T. IOCTL API. And that's what Joey refers to in his next message :)

Related Articles and Replies:

[ DelphiLand: free Delphi source code, tips, tutorials ]