Examples Delphi

Do you need the unix touch utility for Windows? You can write it in Delphi.
This example also shows how to use the functions FindFirst, FindNext and FindClose.
You can download the source and EXE file.

{$APPTYPE CONSOLE}
program touch;
uses
SysUtils;
{$R *.RES}
procedure SetFileDate(TheFileName: string; aDate: TDateTime);
var
f: Integer;
begin { SetFileDate }
f := FileOpen(TheFileName, fmOpenReadWrite);
try
FileSetDate(f, DateTimeToFileDate(aDate));
finally
FileClose(f)
end { try }
end; { SetFileDate }
var
f: TSearchRec;
dtTarget: TDateTime;
begin
dtTarget := Now;
try
if FindFirst(paramstr(1), 255, f)=0 then
repeat
writeln(f.Name);
SetFileDate(f.Name, dtTarget);
until FindNext(f)<>0;
except
FindClose(f);
end; { try }
end.