GetDiskSerial

Reply

Join Date: Jul 2009
Posts: 1
Reputation: Qudrat is an unknown quantity at this point 
Solved Threads: 0
Qudrat Qudrat is offline Offline
Newbie Poster

GetDiskSerial

 
0
  #1
Jul 17th, 2009
Dear Sir,

Please help me on Delphi. Could you tell me how can I get disk serial?
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 444
Reputation: FlamingClaw will become famous soon enough FlamingClaw will become famous soon enough 
Solved Threads: 106
FlamingClaw's Avatar
FlamingClaw FlamingClaw is offline Offline
Posting Pro in Training

Re: GetDiskSerial

 
0
  #2
Jul 18th, 2009
I found a nice function: delphi.about.com
Be a good part of the community.Don't be ungrateful.
If you ask something on the forum and you got the right answer then mark as solved!
If my opinion helped to you a lot then sometimes give reputation point to me.
I'm just a pascal programmer from Hungary.
Farewell...
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 7
Reputation: lad389 is an unknown quantity at this point 
Solved Threads: 2
lad389 lad389 is offline Offline
Newbie Poster

Re: GetDiskSerial

 
0
  #3
Jul 20th, 2009
Pascal and Delphi Syntax (Toggle Plain Text)
  1. type
  2. MIDPtr = ^MIDRec;
  3. MIDRec = Record
  4. InfoLevel: word;
  5. SerialNum: LongInt;
  6. VolLabel: Packed Array [0..10] of Char;
  7. FileSysType: Packed Array [0..7] of Char;
  8. end;
  9.  
  10. function GetDriveSerialNum(MID: MIDPtr; drive: Word): Boolean; assembler;
  11. asm
  12. push DS { Just for safety, I dont think its really needed }
  13. mov ax,440Dh { Function Get Media ID }
  14. mov bx,drive { drive no (0-Default, 1-A ...) }
  15. mov cx,0866h { category and minor code }
  16. lds dx,MID { Load pointeraddr. }
  17. call DOS3Call { Supposed to be faster than INT 21H }
  18. jc @@err
  19. mov al,1 { No carry so return TRUE }
  20. jmp @@ok
  21. @@err:
  22. mov al,0 { Carry set so return FALSE }
  23. @@ok:
  24. pop DS { Restore DS, were not supposed to change it }
  25. end;
  26.  
  27. procedure TForm1.NrBtnClick(Sender: TObject);
  28. var
  29. Info: MIDRec;
  30. begin
  31. Info.InfoLevel:=0; { Information Level }
  32. If GetDriveSerialNum(@Info,0) then { Do something with it... }
  33. ListBox.Items.Add(IntToStr(Info.SerialNum)+' '+Info.VolLabel);
  34. end;
  35. ////////////////////////////////////////////////////
  36. BOOL GetVolumeInformation(
  37.  
  38. LPCTSTR lpRootPathName, // address of root directory of the file system
  39. LPTSTR lpVolumeNameBuffer, // address of name of the volume
  40. DWORD nVolumeNameSize, // length of lpVolumeNameBuffer
  41. LPDWORD lpVolumeSerialNumber, // address of volume serial number
  42. LPDWORD lpMaximumComponentLength, // address of system's maximum filename length
  43. LPDWORD lpFileSystemFlags, // address of file system flags
  44. LPTSTR lpFileSystemNameBuffer, // address of name of file system
  45. DWORD nFileSystemNameSize // length of lpFileSystemNameBuffer
  46. );
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 3
Reputation: coderdan is an unknown quantity at this point 
Solved Threads: 0
coderdan coderdan is offline Offline
Newbie Poster

Re: GetDiskSerial

 
0
  #4
Jul 24th, 2009
Easiest way I do it:

var
VolumeSerialNumber : DWORD;
MaximumComponentLength : DWORD;
FileSystemFlags : DWORD;
TheSerialNumber : String;
begin
if GetVolumeInformation('C:\',nil,0,@VolumeSerialNumber,
MaximumComponentLength,FileSystemFlags,nil,0)
then
begin
TheSerialNumber := IntToHex(HiWord(VolumeSerialNumber), 4) +
IntToHex(LoWord(VolumeSerialNumber), 4);
end;
ShowMessage('The drive serial number is: '+TheSerialNumber);
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Pascal and Delphi Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC