Einzelnen Beitrag anzeigen

musicman56
(Gast)

n/a Beiträge
 
#11

AW: Datei-Änderungsuhrzeit in einer Schleife ändern, 1 Stunde zuviel...

  Alt 19. Feb 2013, 09:32
Hallo,

was macht eigentlich "ChangeFileTimeStamp(FileName, FileDate)" ?

Probier's mal damit:

Delphi-Quellcode:
function RF_SetAllFileDates(FName: string;
                            aCreation,
                            aLastAccess,
                            aLastWrite : TDateTime): boolean;
var
  aHandle: integer;
  FT1, FT2, FT3: TFileTime;
  locFT1, locFT2, locFT3: TFileTime;
  ST1, ST2, ST3 : TSystemTime;
begin
  aHandle := FileOpen(FName, fmOpenWrite or fmShareDenyWrite);
  Result := aHandle >= 0;

  if Result then
  try
    DateTimeToSystemTime(aCreation,ST1);
    DateTimeToSystemTime(aLastAccess,ST2);
    DateTimeToSystemTime(aLastWrite,ST3);

    SystemTimeToFileTime(ST1,FT1);
    SystemTimeToFileTime(ST2,FT2);
    SystemTimeToFileTime(ST3,FT3);

    LocalFileTimeToFileTime(FT1,locFT1);
    LocalFileTimeToFileTime(FT2,locFT2);
    LocalFileTimeToFileTime(FT3,locFT3);

    SetFileTime(aHandle,@locFT1, @locFT2, @locFT3);
  finally
    FileClose(aHandle);
  end;
end;
  Mit Zitat antworten Zitat