//声明: GetDiskFreeSpace( lpRootPathName: PChar; {磁盘根路径} var lpSectorsPerCluster: DWORD; {一个簇内的扇区数} var lpBytesPerSector: DWORD; {一个扇区内的字节数} var lpNumberOfFreeClusters: DWORD; {剩余簇数} var lpTotalNumberOfClusters: DWORD {总簇数} ): BOOL;
//举例: procedure TForm1.FormCreate(Sender: TObject); var d1,d2,d3,d4: DWORD; begin GetDiskFreeSpace('C:',d1,d2,d3,d4); {以下只是显示} Memo1.Clear; with Memo1.Lines do begin Add(Format('一个簇内的扇区数: %d',[d1])); Add(Format('一个扇区内的字节数: %d',[d2])); Add(Format('剩余簇数: %d',[d3])); Add(Format('总簇数: %d',[d4])); Add(Format('剩余空间: %f GB',[d3/1024/1024/1024*d2*d1])); Add(Format('总空间: %f GB',[d4/1024/1024/1024*d2*d1])); end; end;
//效果图: