得到目录大小<br>uses ShellApi<br><br>function GetDirectorySize(Path: String): Integer; //eg. Path = 'c:/temp/'<br>var<br> SR: TSearchRec;<br>begin<br> Result := 0;<br> if FindFirst(Path + '*.*', faAnyFile, SR) = 0 then<br> begin<br> if (sr.Name <> '.') and (sr.Name <> '..') and (sr.Attr = faDirectory) then<br> Result := Result + GetDirectorySize(Path+Sr.Name+'/')<br> else<br> Result := Result + Sr.Size;<br> while FindNext(sr) = 0 do<br> if (sr.Name <> '.') and (sr.Name <> '..') and (sr.Attr = faDirectory) then<br> Result := Result + GetdirectorySize(Path+Sr.Name+'/')<br> else<br> Result := Result + Sr.Size;<br> FindClose(sr);<br> end;<br>end;<br><br><br>得到磁盘的剩余空间:<br>BOOL GetDiskFreeSpace(<br> LPCTSTR lpRootPathName, // root path<br> LPDWORD lpSectorsPerCluster, // sectors per cluster<br> LPDWORD lpBytesPerSector, // bytes per sector<br> LPDWORD lpNumberOfFreeClusters, // free clusters<br> LPDWORD lpTotalNumberOfClusters // total clusters<br>);<br>只需要把lpSectorsPerCluster和lpBytesPerSector和lpNumberOfFreeClusters三个乘起来<br>就行了,得到的是字节数。<br>