Mit diesem Beispiel bekommt man die Festplatteninformation geliefert, wie z. B. Name, Größe, Freier Speicher usw.
Es wird eine DriveComboBox benötigt und die "Procedure SelectNewDisk" muss in das OnEvent-OnChange der
DriveComboBox gewählt werden.
uses FileCtrl
//
procedure TForm1.SelectNewDisk(Sender: TObject);
var BuffNom : Array[0..255]of Char;
BuffSys : Array[0..255]of Char;
Serie, Long, Flags : DWord;
TDrive : String;
FreeBytesAvailable, TotalNumberofBytes, TotalNumberofFreeBytes : TLargeInteger;
begin
GetVolumeInformation(PChar(DriveComboBox1.Drive+':/')
,@BuffNom,SizeOf(BuffNom)
,@Serie
,Long
,Flags
,@BuffSys,SizeOf(BuffSys));
case GetDriveType(PChar(DriveComboBox1.Drive+':/')) of
DRIVE_UNKNOWN : TDrive := 'UNKNOWN';
DRIVE_NO_ROOT_DIR : TDrive := 'Invalid root path';
DRIVE_REMOVABLE : TDrive := 'Removable Disk';
DRIVE_FIXED : TDrive := 'Hard Drive';
DRIVE_REMOTE : TDrive := 'Internet disk';
DRIVE_CDROM : TDrive := 'CD player';
DRIVE_RAMDISK : TDrive := 'RAM Disk';
end;
Label2.Caption := 'Volume Name : '+BuffNom;
Label4.Caption := 'File System : '+BuffSys;
Label3.Caption := 'Serial number : '+IntToStr(Serie);
Label1.Caption := 'Drive : ' + TDrive;
if TDrive <>'' then
GetDiskFreeSpaceEx(PChar(DriveComboBox1.Drive+':/'),
FreeBytesAvailable,
TotalNumberofBytes,
@TotalNumberofFreeBytes);
Label5.Caption := IntToStr(TotalNumberofFreeBytes)+' Free bytes';
Label6.Caption := IntToStr(TotalNumberOfBytes)+' Capacity bytes';
end;
Keine Kommentare:
Kommentar veröffentlichen