Hola Paulao.
A ver si interpreté bién lo que estas buscando...
Código Delphi
[-]
function TextFoundInFile(Ruta: string; const Buscado: string): TStrings;
var
SR: TSearchRec;
txt: TextFile;
Row: string;
Found: Boolean;
begin
Result:= TStringList.Create;
Ruta:= IncludeTrailingPathDelimiter(Ruta);
if FindFirst(Ruta + '*.PAS', $FF, SR) = 0 then
repeat
AssignFile(txt,Ruta + SR.Name);
Reset(txt);
Found:= False;
while not Eof(txt) and not Found do
begin
Readln(txt, Row);
if Pos(Buscado, Row) > 0 then
begin
Result.Add(Ruta + SR.Name);
Found:= True;
end;
end;
CloseFile(txt);
until FindNext(SR) <> 0;
end;
Llamada de ejemplo:
Código Delphi
[-]
procedure TForm1.Button1Click(Sender: TObject);
begin
ListBox1.Items:= TextFoundInFile(edRuta.Text, edBuscado.Text);
TextFoundInFile(edRuta.Text, edBuscado.Text).SaveToFile('C:\LISTA.TXT')
end;
Saludos.