Delphi-如何获取Windows驱动器的总磁盘空间? [英] Delphi - How to get total disk space of Windows drive?

查看:95
本文介绍了Delphi-如何获取Windows驱动器的总磁盘空间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获取Delphi程序中的总磁盘空间。

I need to get total disk space in Delphi program.

推荐答案

使用DiskSize和DiskFree函数可以解决此问题。
ComboBox1包含驱动器号列表。

Use DiskSize and DiskFree functions for this problem. ComboBox1 contains a list of drives letters.

var
  Disk: Integer;
...
procedure TForm1.Button1Click(Sender: TObject);
var
  Total, Free: LongInt;
begin
  Total:=DiskSize(Disk) div 1024;
  Free:=DiskFree(Disk) div 1024;
  Gauge1.MaxValue:=Total;
  Gauge1.Progress:=Free;
  Label1.Caption:='Total size - '+IntToStr(Total);
  Label2.Caption:='Free - '+IntToStr(Free);
end;

procedure TForm1.ComboBox1Change(Sender: TObject);
begin
  Disk:=ComboBox1.ItemIndex+1;
end;

这篇关于Delphi-如何获取Windows驱动器的总磁盘空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆