var
driver:pchar;
sec1, byt1, cl1, cl2:longword;
begin
driver:='c:\';//要显示的驱动器名
GetDiskFreeSpace(driver, sec1, byt1, cl1, cl2);
cl1 := cl1 * sec1 * byt1;
cl2 := cl2 * sec1 * byt1;
Label1.Caption := '该驱动器总共容量' + Formatfloat('###,##0',cl2) + '字节';
Label2.Caption := '该驱动器可用容量' + Formatfloat('###,##0',cl1) + '字节';
end;
我用上面的代码得到的结果和实际结果不一致  为什么

解决方案 »

  1.   

    现在的分区不只2GB大了
    GetDiskFreeSpace只能支持2GB的

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/getdiskfreespace.asp所以当然没正确结果了!MSDN
    The GetDiskFreeSpace function cannot report volume sizes that are greater than 2 gigabytes (GB). To ensure that your application works with large capacity hard drives, use the GetDiskFreeSpaceEx function.用GetDiskFreeSpaceEx就OK

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fileio/base/getdiskfreespaceex.asphttp://lysoft.7u7.net