delphi 获取系统的硬盘分区及使用信息


本文整理自网络,侵删。

  

function GetDiskInfo:string;//获取硬盘信息
var
str:string;
Drivers:Integer;
driver:char;
i,temp:integer;
d1,d2,d3,d4: DWORD;
ss:string;
begin
ss:='';
Drivers:=GetLogicalDrives;
temp:=(1 and Drivers);
for i:=0 to 26 do
begin
    if temp=1 then
    begin
      driver:=char(i+integer('A'));
      str:=driver+':';
      if (driver<>'') and (getdrivetype(pchar(str))<>drive_cdrom) and (getdrivetype(pchar(str))<>DRIVE_REMOVABLE) then
      begin
        GetDiskFreeSpace(pchar(str),d1,d2,d3,d4);
        ss:=ss+str+Format('总空间: %f GB,',[d4/1024/1024/1024*d2*d1])+Format('剩余空间: %f GB',[d3/1024/1024/1024*d2*d1])+'; ';
      end;
    end;
    drivers:=(drivers shr 1);
    temp:=(1 and Drivers);
end;
result:=ss;
end;

编程环境:WindowsXP+Delphi7

相关阅读 >>

Delphi 取得固定长度的随机字符串

Delphi正则表达式匹配中文

Delphi winapi: getnextwindow - 获取指定窗口z上或z下的窗口的句柄

Delphi 检查父进程

Delphi如何获取硬盘所有的分区容量

Delphi 新版 thttpclient组件同步下载文件方法

Delphi 获取含跨域网址的框架网页的源码

Delphi xe6 switch元件�繁�w���}

Delphi2010 的自带的内存泄漏检测

Delphi 内存修改的实现

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...