|
发表于 2020-8-20 20:15:01
|
显示全部楼层
disksize:=0;
for i:=99 to 122 do // 'c'-'z';
begin
drive:=pchar(chr(i)+':\');
x:=GetDriveType(drive);
if x=3 then //3:代表介质是硬盘.
begin
GetDiskFreeSpaceEx(drive,userFreeBytes,totalBytes,@freeBytes);
k:=1000000000;
disksize:=totalBytes div k;
ListItem:=ListView1.Items.Add;
ListItem.Caption:=UpperCase(chr(i))+' 驱动器';
ListItem.SubItems.Add(Formatfloat('###,##0',disksize)+'G');
end;
if x=2 then //removable
begin
GetDiskFreeSpaceEx(drive,userFreeBytes,totalBytes,@freeBytes);
disksize:=totalBytes div 1048576;
ListItem:=ListView1.Items.add;
ListItem.Caption:=UpperCase(chr(i))+' 可移动磁盘';
ListItem.SubItems.Add(inttostr(disksize)+'M');
end;
end; |
|