unit Unit3;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.Menus, Vcl.StdCtrls, Vcl.CheckLst;
type
TForm3 = class(TForm)
MainMenu1: TMainMenu;
N2: TMenuItem;
yf1: TMenuItem;
Button1: TButton;
CheckListBox1: TCheckListBox;
procedure Button1Click(Sender: TObject);
private
public
procedure FindFile(Dir: string);
end;
var
Form3: TForm3;
implementation
{$R *.dfm}
procedure TForm3.Button1Click(Sender: TObject);
begin
CheckListBox1.Clear;
findfile('c:\')
end;
procedure TForm3.FindFile(Dir: string);
var
SR: TSearchRec;
FindRes: Integer;
begin
FindRes := FindFirst(Dir + '*.exe', faAnyFile, SR);
while FindRes = 0 do
begin
if ((SR.Attr and faDirectory) = faDirectory) and
((SR.Name = '.') or (SR.Name = '..')) then
begin
FindRes := FindNext(SR);
Continue;
end;
if ((SR.Attr and faDirectory) = faDirectory) then
begin
FindFile(Dir + SR.Name + '\');
FindRes := FindNext(SR);
Continue;
end;
CheckListBox1.Items.Add(SR.Name);
FindRes := FindNext(SR);
end;
FindClose(SR);
end;
end.