home *** CD-ROM | disk | FTP | other *** search
/ Delphi Programming Unleashed / Delphi_Programming_Unleashed_SAMS_Publishing_1995.iso / chap30 / findallw / main.pas < prev    next >
Pascal/Delphi Source File  |  1995-03-20  |  1KB  |  66 lines

  1. unit Main;
  2.  
  3. { Program copyright (c) 1995 by Charles Calvert }
  4. { Project Name: FINDALLW }
  5.  
  6. { Use this program to iterate through the directories
  7.   on your hard drive and search for files. Enter
  8.   the path where you want to start searching, with
  9.   no backslash at the end, and then enter the mask
  10.   that you want to search with, for instance '*.pas'.
  11. }
  12.  
  13. interface
  14.  
  15. uses
  16.   WinTypes, WinProcs, Classes,
  17.   Graphics, Forms, Controls,
  18.   AllDirs, StdCtrls, Fileiter;
  19.  
  20. type
  21.   TForm1 = class(TForm)
  22.     BStartSearch: TButton;
  23.     ListBox1: TListBox;
  24.     Edit1: TEdit;
  25.     Edit2: TEdit;
  26.     Label1: TLabel;
  27.     Label2: TLabel;
  28.     FileIterator1: TFileIterator;
  29.     procedure BStartSearchClick(Sender: TObject);
  30.   private
  31.     procedure FoundFile(FileName: String);
  32.     { Private declarations }
  33.   public
  34.     { Public declarations }
  35.   end;
  36.  
  37. var
  38.   Form1: TForm1;
  39.  
  40. implementation
  41.  
  42. uses
  43.   SysUtils;
  44.  
  45. {$R *.DFM}
  46.  
  47. procedure TForm1.FoundFile(FileName: String);
  48. begin
  49.   Edit1.Text := FileName;
  50. end;
  51.  
  52. { Make sure the FILEITERATOR's UseFileList property
  53.   is set to true! }
  54. procedure TForm1.BStartSearchClick(Sender: TObject);
  55. var
  56.   RunDir, Start: String;
  57. begin
  58.   Start := Edit1.Text;
  59.   RunDir := Edit2.Text;
  60.   ListBox1.Clear;
  61.   FileIterator1.Run(Start, RunDir);
  62.   ListBox1.Items := FileIterator1.FileList;
  63. end;
  64.  
  65. end.
  66.