Delphi realizes the method of obtaining disk space size _delphi

Source: Internet
Author: User

The Delphi example described in this paper is used to obtain the specified disk space capacity, detect the disk size, and select the disk code from the Combox. By clicking on the "Detect drive" Capacity information button, you can display the total space size of the disk and the size of the capacity to be used below. The reader can add corresponding button and label controls as needed.

The main program code looks like this:

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)//drive name to display
 getdiskfreespace (driver, SEC1, BYT1, CL1, Cl2);
 CL1: = CL1*SEC1 * BYT1;
 Cl2: = CL2*SEC1 * BYT1;
 Label1.caption:= ' The total capacity of the drive ' + formatfloat (' ###,# #0 ', Cl2) + ' byte ';
 Label2.Caption: = ' The drive usable capacity ' + formatfloat (' ###,# #0 ', CL1) + ' byte ';
End;
End.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.