function SetFileSize(FileName: String; Size: int64): boolean;
var
Hi: DWORD;
Attributes: DWORD;
hFile: THandle;
R: integer;
begin
Hi:= DWORD(Size shr 32);
Result:= false;
Attributes:= GetFileAttributes(PCHAR(FileName));
if(Attributes = DWORD(-1)) then Attributes:= FILE_ATTRIBUTE_NORMAL;
SetFileAttributes(PCHAR(FileName), FILE_ATTRIBUTE_NORMAL);
hFile:= CreateFile(PCHAR(FileName), GENERIC_WRITE, 0, nil, OPEN_ALWAYS, FILE_FLAG_WRITE_THROUGH, 0);
if hFile <> THandle(-1) then
begin
if SetFilePointer(hFile, DWORD(Size), @Hi, FILE_BEGIN) <> DWORD(-1) then
begin
Result:= SetEndOfFile(hFile);
end;
CloseHandle(hFile);
end;
SetFileAttributes(PCHAR(FileName), Attributes);
end;