...in einem Verzeichnis-Baum nach einer bestimmten Datei suchen?

Autor: Thomas Stutz

Kategorie: Dateien

uses
  
ImageHlp;

function SearchForFile(const ARootPath: string;
                       const AFileName: string;
                       var APathFound: string): Boolean;
var
  
Found: array[0..500] of Char;
begin
  
FillChar(Found, SizeOf(Found), #00);
  Result := (SearchTreeForFile(PChar(ARootPath), PChar(AFileName), Found) = True);
  APathFound := ExtractFilePath(Found);
end;

procedure TForm1.Button1Click(Sender: TObject);
var
  
APathFound: string;
begin
  if 
SearchForFile('C:\WINDOWS\', 'winhlp32.exe', APathFound) then
    
ShowMessage('winhlp32.exe found in: ' + APathFound);
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base