944,099 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 2378
  • C RSS
Nov 3rd, 2004
0

I want the code of a certain function

Expand Post »
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 ?
Reputation Points: 10
Solved Threads: 0
Newbie Poster
boshkash1986 is offline Offline
1 posts
since Nov 2004
Nov 3rd, 2004
0

Re: I want the code of a certain function

Here is a little Delphi code that gives you just a hint:
  1. // get the hard drive serial number (Delphi Pascal)
  2. procedure TForm1.SerialNumberButtonClick(Sender: TObject);
  3. var
  4. VolumeSerialNumber : DWORD;
  5. MaximumComponentLength : DWORD;
  6. FileSystemFlags : DWORD;
  7. SerialNumber : string;
  8. begin
  9. GetVolumeInformation('c:\',
  10. nil,
  11. 0,
  12. @VolumeSerialNumber,
  13. MaximumComponentLength,
  14. FileSystemFlags,
  15. nil,
  16. 0);
  17. SerialNumber := IntToHex(HiWord(VolumeSerialNumber), 4)
  18. + '-' +
  19. IntToHex(LoWord(VolumeSerialNumber), 4);
  20. Memo1.Lines.Add(SerialNumber);
  21. end;
  22.  
It uses the WinApi function:
  1. BOOL GetVolumeInformation(
  2. LPCTSTR lpRootPathName, // address of root directory of the file system
  3. LPTSTR lpVolumeNameBuffer, // address of name of the volume
  4. DWORD nVolumeNameSize, // length of lpVolumeNameBuffer
  5. LPDWORD lpVolumeSerialNumber, // address of volume serial number
  6. LPDWORD lpMaximumComponentLength, // address of system's maximum filename length
  7. LPDWORD lpFileSystemFlags, // address of file system flags
  8. LPTSTR lpFileSystemNameBuffer, // address of name of file system
  9. DWORD nFileSystemNameSize // length of lpFileSystemNameBuffer
  10. );
Moderator
Reputation Points: 1333
Solved Threads: 1403
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: oop
Next Thread in C Forum Timeline: Need help in os programming





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC