我想在Statusbar状态栏上显示磁盘的容量(比如c:盘的已用容量空间、未用容量空间和总的容量空间),请分别给出代码和标明注释说明,谢谢了!

解决方案 »

  1.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, StdCtrls, FileCtrl,shellapi;type
      TForm1 = class(TForm)
        Label1: TLabel;
        Label2: TLabel;
        Label3: TLabel;
        Label4: TLabel;
        DriveComboBox1: TDriveComboBox;
        Edit1: TEdit;
        Edit2: TEdit;
        Edit3: TEdit;
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
        procedure DriveComboBox1Change(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;  DriverNo:String;
      FreeByte,TotalFreeByte,TotalByte:Int64;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
    begin
    GetdiskFreeSpaceEx(Pchar(driverNo),PLARGEINTEGER(@freebyte)^,PLARGEINTEGER(@totalfreebyte)^,nil);
    totalbyte:=freebyte+totalfreebyte;
    edit1.Text :=inttostr(freebyte div 1024 div 1024 )+'MB';
    edit2.Text :=inttostr(totalfreebyte div 1024 div 1024 )+'MB';
    edit3.Text :=inttostr(totalbyte div 1024 div 1024 )+'MB';end;procedure TForm1.DriveComboBox1Change(Sender: TObject);
    begin
    DriverNo:=DriveComboBox1.Drive +':\';
    end;end.
      

  2.   

    用DriverNo保存你要测试的磁盘目录GetdiskFreeSpaceEx(Pchar(driverNo),PLARGEINTEGER(@freebyte)^,PLARGEINTEGER(@totalfreebyte)^,nil);
    来获得容量等参数
    在edit1.Text edit2.Text edit3.Text 显示
      

  3.   

    补充:用GetVolumeInformation可以得卷的详细信息