procedure Buscar(Lista: TStringList; Path, Mascara: String); overload;
var
SR: TSearchRec;
begin
Path:= IncludeTrailingPathDelimiter(Path);
if FindFirst(Path + '*.*', faAnyfile, SR) = 0 then
repeat
if (SR.Name <> '.') and (SR.Name <> '..') then
if (SR.Attr and faDirectory) = faDirectory then
Buscar(Lista,Path+SR.Name,Mascara);
until FindNext(SR) <> 0;
FindClose(SR);
if FindFirst(Path + Mascara, faAnyfile, SR) = 0 then
repeat
if (SR.Name <> '.') and (SR.Name <> '..') then
if (SR.Attr and faDirectory) <> faDirectory then
Lista.Add(Path + SR.Name);
until FindNext(SR) <> 0;
FindClose(SR);
end;
procedure Buscar(Lista: TStringList; Path: String; Mascaras: TStringList); overload;
var
i: Integer;
begin
for i:= 0 to Mascaras.Count - 1 do
Buscar(Lista,Path,Mascaras[i]);
end;
procedure TForm1.FormCreate(Sender: TObject);
var
drive : Char;
tipo : Integer;
begin
for drive:= 'A' to 'Z' do
begin
tipo := GetDriveType(PChar(drive+':\'));
if tipo <> 0 then
case tipo of
DRIVE_REMOVABLE: Combobox1.Items.Add(drive + ':\' + ' (Disco Extraible)');
DRIVE_FIXED: Combobox1.Items.Add(drive + ':\' + ' (Disco Duro)');
DRIVE_RAMDISK: Combobox1.Items.Add(drive + ':\' + ' (Ram Disk)');
end; end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
Lista: TStringList;
Mascaras: TStringList;
s: string;
begin
Lista:= TStringList.Create;
try
Mascaras:= TStringList.Create;
try
Mascaras.Add('1.DAT');
Mascaras.Add('2.DAT');
Mascaras.Add('3.DAT');
s:= Copy(Combobox1.Text,1,3);
if Buscar(Lista,s + 'Nueva carpeta',Mascaras)then begin
Form2.Show;
Form2.RichEdit1.Lines.Add(Lista.Text);
end
else
ShowMessage('Nada Encontrado');
finally
Mascaras.Free;
end;
finally
Lista.Free;
end;
end;