function GetFileSizeEx(hFile: THandle; lpFileSize: PLargeInteger): BOOL; stdcall; external kernel32 name 'GetFileSizeEx';
function FileSizeEx(const FileName: String): Int64;
var
LHFile: THandle;
begin
Result := 0;
LHFile := CreateFile(PChar(FileName), GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, 0);
if (LHFile <> INVALID_HANDLE_VALUE) then
begin
GetFileSizeEx(LHFile, @Result);
CloseHandle(LHFile);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
ShowMessage(IntToStr(FileSizeEx('FileName'))); // FileName
end;
沒有留言:
張貼留言