Registriert seit: 12. Jul 2004
19 Beiträge
|
Re: "FileSetDate" auch für Ordner?
2. Jun 2006, 20:24
Zitat von himitsu:
Delphi-Quellcode:
Function SetFileAge(Const FileName: AnsiString; Age: TFileTime): Boolean;
Var F: THandle;
Begin
Result := False;
F := CreateFileA(PAnsiChar(FileName), GENERIC_WRITE,
FILE_SHARE_READ or FILE_SHARE_WRITE or FILE_SHARE_DELETE, nil, OPEN_EXISTING, 0, 0);
If F = INVALID_HANDLE_VALUE Then Exit;
{CreateTime} Result := SetFileTime(F, @Age, nil, nil);
{LastAccessTime} Result := SetFileTime(F, nil, @Age, nil);
{LastWriteTime} Result := SetFileTime(F, nil, nil, @Age);
CloseHandle(F);
End;
Funzt nicht bei Ordnern (bei mir). Es muss heißen:
Delphi-Quellcode:
Function SetFileAge(Const FileName: AnsiString; Age: TFileTime): Boolean;
Var F: THandle;
Begin
Result := False;
F := CreateFileA(PAnsiChar(FileName), GENERIC_WRITE,
FILE_SHARE_READ or FILE_SHARE_WRITE or FILE_SHARE_DELETE, nil, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0);
If F = INVALID_HANDLE_VALUE Then Exit;
{CreateTime} Result := SetFileTime(F, @Age, nil, nil);
{LastAccessTime} Result := SetFileTime(F, nil, @Age, nil);
{LastWriteTime} Result := SetFileTime(F, nil, nil, @Age);
CloseHandle(F);
End;
|
|
Zitat
|