1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52:
| type TArrayDateTime = array[0..2] of TDateTime;
const ArrayDateTime : TArrayDateTime = ( 36000, {Erstellt} 36000, {Letzter Zugriff} 36000 ); {Geändert am}
function SetFileDateTime(FileName: string; NewDateTime: TArrayDateTime): Boolean; var FileHandle: Integer; FileTime: TFileTime; LFT: TFileTime; LST: TSystemTime; i: integer; begin Result := False; FileHandle:=-1; for i:=0 to 2 do Begin; try DecodeDate(NewDateTime[i], LST.wYear, LST.wMonth, LST.wDay); DecodeTime(NewDateTime[i], LST.wHour, LST.wMinute, LST.wSecond, LST.wMilliSeconds); if SystemTimeToFileTime(LST, LFT) then begin if LocalFileTimeToFileTime(LFT, FileTime) then begin FileHandle := FileOpen(FileName, fmOpenReadWrite or fmShareExclusive); case i of 0: if SetFileTime(FileHandle, @FileTime, nil, nil ) then Result := Result and True; 1: if SetFileTime(FileHandle, nil, @FileTime, nil ) then Result := Result and True; 2: if SetFileTime(FileHandle, nil, nil, @FileTime ) then Result := Result and True; end; end; end; finally FileClose(FileHandle); end; End; end;
prcocedure run; Begin; if SetFileDateTime('C:\config.sys',ArrayDateTime) then Label1.Caption:='Dateidatum wurde geändert.' End; |