interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
Sp:string;//SearchPath;
sl:TStringList;
function Exists(s:string):Boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function TForm1.Exists(s:string):Boolean;
var i:Integer;
b:Boolean;
begin
b:=false;
for i:=0 to sl.Count-1do
begin
if sl=s then
begin
b:=true;
break;
end;
end;
result:=b;
end;
procedure TForm1.Button1Click(Sender: TObject);
var sr:TSearchRec;
begin
FindFirst(sp,faAnyFile,sr);
FindNext(sr);
while FindNext(sr)=0do
begin
if Exists(ExtractFileExt(sr.Name)) then
begin
ListBox1.Items.Add(sr.Name);
end;
end;
FindClose(sr);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
sl:=TStringList.Create;
sl.Add('.avi');
sl.Add('.mp3');
sl.Add('.rm');
sp:='e:/music/*.*';
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
sl.Free;
end;
end.