954,168 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

I want the code of a certain function

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 ?

boshkash1986
Newbie Poster
1 post since Nov 2004
Reputation Points: 10
Solved Threads: 0
 

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 
);
vegaseat
DaniWeb's Hypocrite
Moderator
5,976 posts since Oct 2004
Reputation Points: 1,345
Solved Threads: 1,416
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You