| | |
GetDiskSerial
![]() |
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...
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...
•
•
Join Date: Jul 2009
Posts: 7
Reputation:
Solved Threads: 2
Pascal and Delphi Syntax (Toggle Plain Text)
type MIDPtr = ^MIDRec; MIDRec = Record InfoLevel: word; SerialNum: LongInt; VolLabel: Packed Array [0..10] of Char; FileSysType: Packed Array [0..7] of Char; end; function GetDriveSerialNum(MID: MIDPtr; drive: Word): Boolean; assembler; asm push DS { Just for safety, I dont think its really needed } mov ax,440Dh { Function Get Media ID } mov bx,drive { drive no (0-Default, 1-A ...) } mov cx,0866h { category and minor code } lds dx,MID { Load pointeraddr. } call DOS3Call { Supposed to be faster than INT 21H } jc @@err mov al,1 { No carry so return TRUE } jmp @@ok @@err: mov al,0 { Carry set so return FALSE } @@ok: pop DS { Restore DS, were not supposed to change it } end; procedure TForm1.NrBtnClick(Sender: TObject); var Info: MIDRec; begin Info.InfoLevel:=0; { Information Level } If GetDriveSerialNum(@Info,0) then { Do something with it... } ListBox.Items.Add(IntToStr(Info.SerialNum)+' '+Info.VolLabel); end; //////////////////////////////////////////////////// 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 );
•
•
Join Date: Apr 2005
Posts: 3
Reputation:
Solved Threads: 0
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);
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);
![]() |
Similar Threads
- Help with automatic update problem and more (Viruses, Spyware and other Nasties)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: Layered window controls dissapearing?
- Next Thread: Working with threads
| Thread Tools | Search this Thread |





