/[projects]/dao/DelphiScanner/Components/tpsystools_4.04/examples/Delphi/ExEnumFU.pas
ViewVC logotype

Contents of /dao/DelphiScanner/Components/tpsystools_4.04/examples/Delphi/ExEnumFU.pas

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2671 - (show annotations) (download)
Tue Aug 25 18:15:15 2015 UTC (8 years, 9 months ago) by torben
File size: 3470 byte(s)
Added tpsystools component
1 (* ***** BEGIN LICENSE BLOCK *****
2 * Version: MPL 1.1
3 *
4 * The contents of this file are subject to the Mozilla Public License Version
5 * 1.1 (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 * http://www.mozilla.org/MPL/
8 *
9 * Software distributed under the License is distributed on an "AS IS" basis,
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11 * for the specific language governing rights and limitations under the
12 * License.
13 *
14 * The Original Code is TurboPower SysTools
15 *
16 * The Initial Developer of the Original Code is
17 * TurboPower Software
18 *
19 * Portions created by the Initial Developer are Copyright (C) 1996-2002
20 * the Initial Developer. All Rights Reserved.
21 *
22 * Contributor(s):
23 *
24 * ***** END LICENSE BLOCK ***** *)
25
26 unit ExEnumFU;
27
28 interface
29
30 uses
31 Windows, Messages, SysUtils, Classes, Graphics, Controls,
32 Forms, Dialogs, StdCtrls;
33
34 type
35 TForm1 = class(TForm)
36 Button1: TButton;
37 Edit1: TEdit;
38 CheckBox1: TCheckBox;
39 ListBox1: TListBox;
40 Label1: TLabel;
41 CheckBox2: TCheckBox;
42 Button2: TButton;
43 procedure FormCreate(Sender: TObject);
44 procedure Button1Click(Sender: TObject);
45 procedure Button2Click(Sender: TObject);
46 procedure FormDestroy(Sender: TObject);
47 private
48 { Private declarations }
49 public
50 { Public declarations }
51 AList : TStringList;
52 end;
53
54 var
55 Form1: TForm1;
56
57 implementation
58
59 {$R *.DFM}
60
61 uses
62 StConst,
63 StBase,
64 StSystem;
65
66 var
67 StopIt : Boolean;
68
69 function ProcessAll(const SR : TSearchRec; ForInclusion : Boolean;
70 var Abort : Boolean) : Boolean;
71 begin
72 Abort := False;
73 if StopIt then begin
74 Abort := True;
75 Result := False;
76 end
77 else begin
78 Application.ProcessMessages;
79 Result := True;
80 end;
81 end;
82
83 function TextFilesOnly(const SR : TSearchRec; ForInclusion : Boolean;
84 var Abort : Boolean) : Boolean;
85 var
86 S : String;
87 begin
88 Abort := False;
89 if StopIt then begin
90 Abort := True;
91 Result := False;
92 end
93 else begin
94 Application.ProcessMessages;
95
96 if ForInclusion then begin
97 Result := False;
98 S := SR.Name;
99 if (UpperCase(ExtractFileExt(S)) = '.TXT') or
100 ((SR.Attr and faDirectory) > 0) then
101 Result := True;
102 end
103 else
104 Result := True;
105
106 end;
107 end;
108
109 procedure TForm1.FormCreate(Sender: TObject);
110 begin
111 AList := TStringList.Create;
112 Edit1.Text := 'C:\';
113 end;
114
115 procedure TForm1.Button1Click(Sender: TObject);
116 var
117 I : longint;
118 begin
119 AList.Clear;
120 ListBox1.Clear;
121
122 Screen.Cursor := crHourGlass;
123 StopIt := False;
124
125 if not CheckBox2.Checked then begin
126 EnumerateFiles(Edit1.Text, AList, CheckBox1.Checked, ProcessAll);
127 ListBox1.Items := AList;
128 end else begin
129 EnumerateFiles(Edit1.Text, AList, CheckBox1.Checked, TextFilesOnly);
130 {by its nature, EnumerateFiles also returns directory names}
131 {remove those from the list - leaving only the text files}
132 for I := 0 to AList.Count-1 do
133 if (UpperCase(ExtractFileExt(AList[I])) = '.TXT') then
134 ListBox1.Items.Add(AList[I]);
135 end;
136
137 Screen.Cursor := crDefault;
138 ListBox1.Update;
139 end;
140
141 procedure TForm1.Button2Click(Sender: TObject);
142 begin
143 StopIt := True;
144 end;
145
146 procedure TForm1.FormDestroy(Sender: TObject);
147 begin
148 AList.Free;
149 end;
150
151 end.

  ViewVC Help
Powered by ViewVC 1.1.20