Delphi完成獲得磁盤空間年夜小的辦法。本站提示廣大學習愛好者:(Delphi完成獲得磁盤空間年夜小的辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是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) + '字節';
Label2.Caption := '該驅動器可用容量' + Formatfloat('###,##0',cl1) + '字節';
end;
end.