function FileSize(const AFileName: string): Int64; var srData: TSearchRec; FileData: DWORD; SizeHigh, SizeLow: Integer; RetVal: array[0..7] of Byte; begin Result := -1; {$IFDEF MSWINDOWS} FileData := FindFirst(AFileName, faReadOnly, srData); if FileData <> 0 then Exit; SizeHigh := srData.FindData.nFileSizeHigh; SizeLow := srData.FindData.nFileSizeLow; ZeroMemory(@RetVal[0], SizeOf(RetVal)); Move(SizeLow, RetVal[0], 4); Move(SizeHigh, RetVal[4], 4); Move(RetVal[0], Result, 8); {$ENDIF} end;
Delphi/C++Builder