Tach!
Vorher die Komponente auf deinem Formular mit dem Designer in "Listbox1" umbenennen...
Delphi-Quellcode:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons;
type
TForm1 =
class(TForm)
Listbox1: TListBox;
BitBtn1: TBitBtn;
procedure BitBtn1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
procedure FindAll(Path:
String; Items: TStrings);
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
Listbox1.Clear;
FindAll('
c:/', Listbox1.items);
end;
procedure TForm1.FindAll(Path:
String; Items: TStrings);
var
SearchRec: TSearchRec;
begin
If not Assigned(Items)
then exit;
if FindFirst(Path + '
*.*', faAnyFile, SearchRec) = 0
then
repeat
Items.Add(SearchRec.
Name);
until FindNext(SearchRec) <> 0;
SysUtils.FindClose(SearchRec);
end;
end.
Edit: Ups...hab was übersehen
Edit Nr5: Okay TListbox.items ist vom Typ TStrings und nicht TStringlist
Dani H.