DiskFree (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example uses a form with a label on it. When the following code executes, it displays a message in the label indicating the number of KB free, and what percentage of the entire disk space that represents.

Code

procedure TForm1.Button1Click(Sender: TObject);
var
  S: string;
  AmtFree: Int64;
  Total:   Int64;
begin
  AmtFree := SysUtils.DiskFree(0);
  Total := DiskSize(0);
  S := IntToStr((AmtFree  * 100) div Total) + ' percent of the space on drive 0 is free: ' + IntToStr(AmtFree div 1024) + ' Kbytes free. ';
  Label1.Caption := S;
end;

Uses