Unconfigured Ad Widget

Collapse

Anúncio

Collapse
No announcement yet.

Função de Pesquisa

Collapse
X
 
  • Filter
  • Tempo
  • Show
Clear All
new posts

  • Font Size
    #1

    Delphi Função de Pesquisa

    Função para encontramos algum determinado arquivo,que muitas vezes esteja com problema sendo eles possivelmente: dll,exe,etc

    Código:
    function TForm1.Busca(const cPath, cFile: String): Boolean;
    var
    S: String;
    nRet: Integer;
    Search: TSearchRec;
    begin
    nRet := FindFirst(cPath+'*.*',faAnyFile or faArchive or faDirectory,Search);
    while nRet = 0 do
    begin
    if (Trim(Search.Name)<>‘.’) and (Trim(Search.Name)<>‘..’) then
    begin
    { Se for um diretório, chama a função para percorrê-lo. }
    if Search.Attr and faDirectory > 0 then
    Busca(IncludeTrailingPathDelimiter(cPath+Search.Name), cFile)
    { Neste caso estamos fazendo uma busca exata, pode-se fazer um if com pos para buscar extensões
    partes do nome e etc. }
    else if Trim(Search.Name) = cFile then
    Memo1.Lines.Add(cPath+Search.Name);
    end;
    nRet := FindNext(Search);
    end;
    end;
    
    Exemplo de uso:
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    Busca('C:\Windows\','arquivo.dll');
    end;
    ~# Criado pela [IN]Segurança #~
X
Working...
X