欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Delphi實現獲取磁盤空間大小的方法

 更新時間:2014年07月24日 11:16:56   投稿:shichen2014  
這篇文章主要介紹了Delphi實現獲取磁盤空間大小的方法,是一個很實用的功能,需要的朋友可以參考下

本文所述Delphi實例用以獲取指定的磁盤空間容量大小,檢測磁盤大小,從combox中選擇磁盤代號等功能。點擊“檢測驅動器”容量信息的按鈕,就可以在下邊顯示出該磁盤的總空間大小以及要用容量的大小。讀者可根據需求添加對應的Button與label控件。

主要程序代碼如下所示:

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);//要顯示的驅動器名
 GetDiskFreeSpace(driver, sec1, byt1, cl1, cl2);
 cl1 := cl1*sec1 * byt1;
 cl2 := cl2*sec1 * byt1;
 Label1.Caption:= '該驅動器總共容量' + Formatfloat('###,##0',cl2) + '字節(jié)';
 Label2.Caption := '該驅動器可用容量' + Formatfloat('###,##0',cl1) + '字節(jié)';
end;
end.

相關文章

最新評論