Mega Code Archive

 
Categories / Delphi / Hardware
 

How to get the free disk space

Title: How to get the free disk space procedure TForm1.Button1Click(Sender: TObject); var freeSpace, totalSpace: Double; s: Char; begin // Drive letter // Laufwerksbuchstabe s := 'D'; freeSpace := DiskFree(Ord(s) - 64); totalSpace := DiskSize(Ord(s) - 64); label1.Caption := Format('Free Space: %12.0n', [freeSpace]); Label2.Caption := Format('Total Space: %12.0n', [totalSpace]); Label3.Caption := IntToStr(Round((totalSpace - freeSpace) / totalSpace * 100)) + ' Percent used.'; end;