Here's a procedure to change the created date "attribute" for a given file:
function SetFileDate(Const FileName : String;Const FileDate : TDateTime): Boolean;
var
___FileHandle : THandle;
___FileSetDateResult : Integer;
begin
___try
______try
_________FileHandle := FileOpen(FileName,fmOpenWrite OR fmShareDenyNone) ;
_________if FileHandle > 0 Then
_________begin
____________FileSetDateResult :=
____________ FileSetDate(FileHandle,DateTimeToFileDate(FileDate)) ;
____________result := (FileSetDateResult = 0) ;
_________end;
_________except
_________Result := False;
______end;
___finally
______FileClose (FileHandle) ;
___end;
end;
{Usage:}
SetFileDate('c:\mydir\myfile.ext', Now)
1 comment:
test
Post a Comment