Ver Mensaje Individual
  #9  
Antiguo 31-08-2010
Avatar de escafandra
[escafandra] escafandra is offline
Miembro Premium
 
Registrado: nov 2007
Posts: 2.197
Reputación: 20
escafandra Tiene un aura espectacularescafandra Tiene un aura espectacular
Código Delphi [-]
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;


Saludos.
Responder Con Cita