获得磁盘空间

procedure GetDiskInfo(var TotalSize,FreeSize:Integer;Disk:string); //单位为兆(M)

var

freespace,totalspace:int64;

begin

if (Pos('\',TrimRight(Disk)<>Length(Disk) then

Disk :=Disk+'\';

GetDiskFreeSpaceEx(pchar(Disk),freespace,totalspace,nil);

TotalSize :=totalspace div 1024 div 1024;

freesize:=freespace div 1024 div 1024;

end;

//例如: GetDiskInfo(totalspace,freespace,'C:\');

原文地址:https://www.cnblogs.com/djcsch2001/p/2035788.html