标签:
class function TDuoFile.GetFileSize(const AFile: TFileName): Int64; var sr:TSearchRec; begin if FindFirst(AFile,faAnyFile and (not faDirectory),sr) = 0 then Result := sr.Size else Result := 0; FindClose(sr); // Windows.GetFileSizeEx() // 这个函数是新API // 另一种写法 //var hh:THandle;dwSizeLow,dwSizeHigh:Cardinal; //begin // hh := FileOpen(PChar(OpenDialog1.FileName),fmOpenRead); // dwSizeLow := GetFileSize(hh,@dwSizeHigh); // Result := dwSizeHigh shl 32 + dwSizeLow; // CloseHandle(hh); //end; end; class function TDuoFile.GetFileSizeCompressed(const AFile: TFileName): Int64; begin Int64Rec(Result).Lo := GetCompressedFileSize(PAnsiChar(AFile),@Int64Rec(Result).Hi); // 另一种写法 //var dwSizeLow,dwSizeHigh:Cardinal; //begin // dwSizeLow := GetCompressedFileSize(PAnsiChar(AFile),@dwSizeHigh); // Result := dwSizeHigh shl 32 + dwSizeLow; //end; end;
标签:
原文地址:http://www.cnblogs.com/LittleTiger/p/4437058.html