>>430
1、 手続きを作る時は出来るだけ依存関係を引数に纏める事
2、 再帰を使う時は関数内関数を使うと格好良く書ける

procedure filesearch(ddir:string;ListBox1:TListBox);
var filelist :TStrings;
 procedure files(ddir:string);
 var sr:TsearchRec;
 ext:string;
 res:integer;
 begin
   res:=FindFirst(ddir+'\*.*',faAnyFile,sr);
   try
    while res=0 do
    begin
     if not ((SR.Name='.') or (SR.Name='..')) then
     if ((SR.Attr and faDirectory) = faDirectory) then files(ddir + '\' + SR.Name) //対象がディレクトリの場合、自分を再帰呼び出し
    else
      begin //対象がファイルの場合リストに追加
       ext:=LowerCase(extractfileext(sr.name));
        if (ext='.jpg') or (ext='.jpeg') or (ext='.bmp') then filelist.Add(ddir +'\'+sr.name);
      end;
    res:=FindNext(sr);
    end; //while end
   finally findclose(sr); end;
 end;
var i:integer;
begin
ListBox1.Items.BeginUpdate;
filelist:=TStringList.Create;
try
  files(ddir);
  ListBox1.Items.Assign(filelist);
 finally filelist.free;end;
for i := 0 to ListBox1.Count-1 do
begin
  ListBox1.Items[i]:=ExtractFileName(ListBox1.Items[i]);
end;
ListBox1.Items.EndUpdate;
end;