Delphi實現擷取磁碟空間大小的方法_Delphi

來源:互聯網
上載者:User

本文所述Delphi執行個體用以擷取指定的磁碟空間容量大小,檢測磁碟大小,從combox中選擇磁碟代號等功能。點擊“檢測磁碟機”容量資訊的按鈕,就可以在下邊顯示出該磁碟的總空間大小以及要用容量的大小。讀者可根據需求添加對應的Button與label控制項。

主要程式碼如下所示:

unit Unit1;interfaceuses 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.

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.