Start New Discussion within our Software Development Community

Please i want the code of the function which could get the serial number of the Hard-disk of any computer

Please Can anyone help ?

Here is a little Delphi code that gives you just a hint:

// get the hard drive serial number (Delphi Pascal)
procedure TForm1.SerialNumberButtonClick(Sender: TObject);
var
  VolumeSerialNumber : DWORD;
  MaximumComponentLength : DWORD;
  FileSystemFlags : DWORD;
  SerialNumber : string;
begin
  GetVolumeInformation('c:\',
                       nil,
                       0,
                       @VolumeSerialNumber,
                       MaximumComponentLength,
                       FileSystemFlags,
                       nil,
                       0);
  SerialNumber := IntToHex(HiWord(VolumeSerialNumber), 4)
                  + '-' +
                  IntToHex(LoWord(VolumeSerialNumber), 4);
  Memo1.Lines.Add(SerialNumber);
end;

It uses the WinApi function:

BOOL GetVolumeInformation(
    LPCTSTR lpRootPathName,	// address of root directory of the file system 
    LPTSTR lpVolumeNameBuffer,	// address of name of the volume 
    DWORD nVolumeNameSize,	// length of lpVolumeNameBuffer 
    LPDWORD lpVolumeSerialNumber,	// address of volume serial number 
    LPDWORD lpMaximumComponentLength,	// address of system's maximum filename length
    LPDWORD lpFileSystemFlags,	// address of file system flags 
    LPTSTR lpFileSystemNameBuffer,	// address of name of file system 
    DWORD nFileSystemNameSize 	// length of lpFileSystemNameBuffer 
);
This question has already been answered. Start a new discussion instead.