DelphiFAQ Home Search:

Touch for Windows in Delphi

 

commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.

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.
You don't like the formatting? Check out SourceCoder then!

Comments:

 

 

Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option.
 
It seems that you are
from Los Angeles, US .

Info/ Feedback on this

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:
photo Add a picture:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity. The owner of this web site reserves the right to delete such material.