Windows with Delphi Windows API (94) Windows Filesystem (41) Windows Forms (69) Windows Graphics (38)
Exchange Links About this site Links to us 
|
Touch for Windows in Delphi
This 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.  | |  | |
program touch;
uses
SysUtils;
procedure SetFileDate(TheFileName: string; aDate: TDateTime);
var
f: Integer;
begin
f := FileOpen(TheFileName, fmOpenReadWrite);
try
FileSetDate(f, DateTimeToFileDate(aDate));
finally
FileClose(f)
end
end;
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;
end. | |  | |  | You don't like the formatting? Check out SourceCoder then!
Comments:
|