unit DiskFree;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

// BeginExample: DiskFree
// Routine: SysUtils.DiskFree
// Routine: SysUtils.DiskSize

// BeginCode
{
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.
} 
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;
// EndCode
// EndExample: DiskFree
end.
