home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programming Unleashed / Delphi_Programming_Unleashed_SAMS_Publishing_1995.iso / misc / wtouch / main.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-03-21  |  2.3 KB  |  92 lines

  1. unit Main;
  2.  
  3. { Program copyright (c) 1995 by Charles Calvert }
  4. { Project Name: WTOUCH }
  5.  
  6. { This program works the same way Borland's TOUCH.COM for
  7.   DOS works. Enter a data and a time: 01/01/56 05:00:00AM
  8.   and choose a directory. The program will then iterate
  9.   through that directory and all nested directories under
  10.   it and set the file date to the date and time that
  11.   you specify. }
  12.  
  13. interface
  14.  
  15. uses
  16.   SysUtils, WinTypes, WinProcs,
  17.   Messages, Classes, Graphics,
  18.   Controls, Forms, Dialogs,
  19.   AllDirs, Fileiter, StdCtrls,
  20.   FileCtrl, Mask, Buttons;
  21.  
  22. const
  23.   HelpStr: PChar =
  24.     'This program works the same way Borland''s TOUCH.COM for ' +
  25.     'DOS works. Enter a data and a time: 01/01/56 05:00:00AM ' +
  26.     'and choose a directory. The program will then iterate ' +
  27.     'through that directory and all nested directories under ' +
  28.     'it and set the file date/time.';
  29.  
  30. type
  31.   TForm1 = class(TForm)
  32.     FileIterator1: TFileIterator;
  33.     Label1: TLabel;
  34.     DirectoryListBox1: TDirectoryListBox;
  35.     DriveComboBox1: TDriveComboBox;
  36.     Label2: TLabel;
  37.     Label3: TLabel;
  38.     MaskEdit1: TMaskEdit;
  39.     MaskEdit2: TMaskEdit;
  40.     BTouch: TBitBtn;
  41.     BHelp: TBitBtn;
  42.     BClose: TBitBtn;
  43.     procedure FileIterator1FoundFile(FileName: String; SR: TSearchRec);
  44.     procedure RunTouchClick(Sender: TObject);
  45.     procedure BHelpClick(Sender: TObject);
  46.     procedure BCloseClick(Sender: TObject);
  47.   private
  48.     { Private declarations }
  49.   public
  50.     { Public declarations }
  51.   end;
  52.  
  53. var
  54.   Form1: TForm1;
  55.  
  56. implementation
  57.  
  58. {$R *.DFM}
  59.  
  60. procedure TForm1.FileIterator1FoundFile(FileName: String; SR: TSearchRec);
  61. var
  62.   F: file;
  63.   DateTime: TDateTime;
  64.   Age: LongInt;
  65. begin
  66.   System.Assign(F, FileName);
  67.   Reset(F);
  68.   DateTime := StrToDateTime(MaskEdit1.Text + ' ' + MaskEdit2.Text);
  69.   Age := DateTimeToFileDate(DateTime);
  70.   FileSetDate(TFileRec(F).Handle, Age);
  71.   System.Close(F);
  72.   Label1.Caption := FileName;
  73.   Application.ProcessMessages;
  74. end;
  75.  
  76. procedure TForm1.RunTouchClick(Sender: TObject);
  77. begin
  78.   FileIterator1.Run('*.*', DirectoryListBox1.Directory);
  79. end;
  80.  
  81. procedure TForm1.BHelpClick(Sender: TObject);
  82. begin
  83.   MessageBox(Handle, HelpStr, 'Touch for Windows', mb_Ok or mb_IconInformation);
  84. end;
  85.  
  86. procedure TForm1.BCloseClick(Sender: TObject);
  87. begin
  88.   Close;
  89. end;
  90.  
  91. end.
  92.