Delphi implementation method to get the size of disk space

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
Label1: TLabel;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
driver:pchar;
sec1, byt1, cl1, cl2:longword;
begin
driver:=pchar(edit1.text);//要显示的驱动器名
The GetDiskFreeSpace (Driver, SEC1, byt1, CLl, CL2);
CLl: SEC1 * * = CLl byt1;
CL2: CL2 = SEC1 * * byt1;
Label1.Caption: = 'a total capacity of the drive' + Formatfloat ( '###, ## 0 ', cl2) +' byte ';
Label2.Caption: =' available capacity of the drive '+ Formatfloat (' ###, ## 0 ', cl1) +' byte ';
End;
End.

Guess you like

Origin www.cnblogs.com/blogpro/p/11446118.html