unit1.pas

来自「Delphi7应用编程150例附书源码.rar」· PAS 代码 · 共 42 行

PAS
42
字号
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    DriveComboBox1: TDriveComboBox;
    Edit1: TEdit;
    Label1: TLabel;
    Edit2: TEdit;
    Label2: TLabel;
    procedure DriveComboBox1Change(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.DriveComboBox1Change(Sender: TObject);
var
    driver:Char;
    userFreeBytes,totalBytes,freeBytes:Int64;
begin
  driver:=self.DriveComboBox1.Drive;
  GetDiskFreeSpaceEx(PChar(driver+':\'),userFreeBytes,totalBytes,@freeBytes);
  Edit1.Text:=Formatfloat('###,##0',totalBytes)+'字节';
  Edit2.Text:=Formatfloat('###,##0',freeBytes)+'字节';
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?