Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Varios (https://www.clubdelphi.com/foros/forumdisplay.php?f=11)
-   -   Cambiando la fecha de creacion de un archivo (https://www.clubdelphi.com/foros/showthread.php?t=54124)

cascarrabias 10-03-2008 06:37:21

Cambiando la fecha de creacion de un archivo
 
Buen dia, he estado tratando de cambiar la fecha de creacion de un archivo con el siguiente procedimiento...

Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
var
A: Integer;
Fecha: LongInt;
SFecha: TDateTime;
begin

if not opendialog1.Execute then exit
  else
  begin
  A := FileOpen(OpenDialog1.FileName, fmOpenReadWrite or fmShareDenyWrite);
  SFecha := StrToDateTime('10/05/1983 0:0:0');
  Fecha := DateTimeToFileDate(SFecha);
  FileSetDate(A, Fecha);
  FileClose(A);
  end;

end;

El procedimiento cambia correctamente la fecha y hora pero la del atributo "modificado:", estoy tratando de que cambie pero de la fecha de "creacion", alguien sabe si hay alguna manera de cambiar esto?
Gracias por su tiempo.

cHackAll 10-03-2008 14:59:46

Código Delphi [-]
procedure TForm1.Button1Click(Sender: TObject);
var hFile: Cardinal; SystemTime: TSystemTime; CreationTime: TFileTime;
begin
 if not OpenDialog1.Execute then Exit;
 hFile := _lopen(PChar(OpenDialog1.FileName), OF_WRITE);
 DateTimeToSystemTime(StrToDateTime('10/05/1983 0:0:0'), SystemTime);
 SystemTimeToFileTime(SystemTime, CreationTime);
 SetFileTime(hFile, @CreationTime, nil, nil);
 CloseHandle(hFile);
end;

cascarrabias 10-03-2008 18:24:48

Gracias
 
Cita:

Empezado por cHackAll (Mensaje 271998)
Código Delphi [-]procedure TForm1.Button1Click(Sender: TObject);
var hFile: Cardinal; SystemTime: TSystemTime; CreationTime: TFileTime;
begin if not OpenDialog1.Execute then Exit;
hFile := _lopen(PChar(OpenDialog1.FileName), OF_WRITE);
DateTimeToSystemTime(StrToDateTime('10/05/1983 0:0:0'), SystemTime);
SystemTimeToFileTime(SystemTime, CreationTime);
SetFileTime(hFile, @CreationTime, nil, nil);
CloseHandle(hFile);
end;



Gracias men, me sirvio de mucha ayuda tu codigo, solo le cambie un poco porque no me andaba del todo....saludos y muchas gracias....aqui dejo el codigo como me lo quede...

Código Delphi [-]

procedure TForm1.Button1Click(Sender: TObject);
var
A: Cardinal;
CreationTime: TFileTime;
SystemTime: TSystemTime;
begin
if not opendialog1.Execute then exit
  else
  begin
  A := FileOpen(OpenDialog1.FileName, fmOpenReadWrite or fmShareDenyWrite);
  DateTimeToSystemTime(StrToDateTime('10/05/1983 0:0:0'),SystemTime);
  SystemTimeToFileTime(SystemTime, CreationTime);
  SetFileTime(A, @CreationTime, nil, nil);
  FileClose(A);
  end;

end;


end.


La franja horaria es GMT +2. Ahora son las 16:04:08.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi