Delphi gets the file size. The file size can exceed 2GB

From , 4 Years ago, written in Delphi (Object Pascal), viewed 214 times.
URL https://pastebin.vip/view/f0e6be4c
  1. function SizeOfFile64(const FileName: string): Int64;
  2. var
  3.   FH: THandle;  // file handle
  4. begin
  5.   FH := SysUtils.FileOpen(
  6.     FileName, SysUtils.fmOpenRead or SysUtils.fmShareDenyNone
  7.   );
  8.   try
  9.     SysUtils.Int64Rec(Result).Lo := Windows.GetFileSize(
  10.       FH, @SysUtils.Int64Rec(Result).Hi
  11.     );
  12.     if (SysUtils.Int64Rec(Result).Lo = $FFFFFFFF) and
  13.       (Windows.GetLastError <> Windows.NO_ERROR) then
  14.       Result := -1;
  15.   finally
  16.     SysUtils.FileClose(FH);
  17.   end;
  18. end;
  19. //delphi/2226

Reply to "Delphi gets the file size. The file size can exceed 2GB"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website