Ada cara yang bisa digunakan untuk mengetahui kapasitas harddisk dengan delphi.
Berikut source code untuk mengetahui kapasitas pada drive C,D,E :
procedure TForm1.FormCreate(Sender: TObject);
var freeSpace, totalSpace: Double;
C,D,E,F,G: Char;
begin
C := ‘C’;
D := ‘D’;
E := ‘E’;
G := ‘G’;
freeSpace := DiskFree(Ord(C) – 64);
totalSpace := DiskSize(Ord(C) – 64);
LabeledEdit1.Text:= Format(‘%12.0n’, [freeSpace]);
LabeledEdit2.Text:= Format(‘%12.0n’, [totalSpace]);
LabeledEdit3.Text:= IntToStr(Round((totalSpace – freeSpace) / totalSpace * 100)) + ‘ Persen.’;
freeSpace := DiskFree(Ord(D) – 64);
totalSpace := DiskSize(Ord(D) – 64);
LabeledEdit4.Text:= Format(‘%12.0n’, [freeSpace]);
LabeledEdit5.Text:= Format(‘%12.0n’, [totalSpace]);
LabeledEdit6.Text:= IntToStr(Round((totalSpace – freeSpace) / totalSpace * 100)) + ‘ Persen.’;
freeSpace := DiskFree(Ord(G) – 64);
totalSpace := DiskSize(Ord(G) – 64);
LabeledEdit7.Text:= Format(‘%12.0n’, [freeSpace]);
LabeledEdit8.Text:= Format(‘%12.0n’, [totalSpace]);
LabeledEdit9.Text:= IntToStr(Round((totalSpace – freeSpace) / totalSpace * 100)) + ‘ Persen.’;
end;
bila ingin banyak drive yang dideteksi silahkan tambahkan sendiri drivenya, jika ingin aplikasi dijalankan secara realtime masukkan script tersebut kedalam event timer.
Untuk contoh aplikasinya silahkan download disini
Comments (0)





