AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Search for multiple files at once in PC

Ein Thema von danten · begonnen am 31. Dez 2012 · letzter Beitrag vom 2. Jan 2013
 
danten

Registriert seit: 19. Feb 2012
Ort: Czech Republic, Prag
126 Beiträge
 
Delphi 10.1 Berlin Architect
 
#1

Search for multiple files at once in PC

  Alt 31. Dez 2012, 16:31
Hi all,
please help.
How do I write a function to search for multiple files on your computer at once.
I need to find files:
abcd.exe, 1234.ini, GHIJ.BAT, 0987.dat, tinyplay.exe !!
I use to find one set this feature:
Delphi-Quellcode:
function Tfindplayer.ScanL7(root, filemask: string; hitlist: String): Boolean;
  function ScanDirectory(var path: string): Boolean;
  var
    SRec: TSearchRec;
    pathlen: Integer;
    res: Integer;
  begin
    pathlen := Length(path);
    { first pass, files }
    res := FindFirst(path + filemask, faAnyfile+faHidden, SRec);
    If (FileExists(path+'tinyplay.exe') = True) then
      begin
        FScanAborted := True;
        sLabel24.Caption := ExtractShortPathName(ExcludeTrailingBackslash(sLabel24.Caption));
        sProgressBar1.Position := sProgressBar1.Position + 10;
        image12.Picture.Assign(x1);
        Exit;
      end;
    if res = 0 then
      try
        while res = 0 do
        begin
          hitlist := (path + SRec.Name);
          res := FindNext(SRec);
        end;
      finally
        FindClose(SRec);
      end;
    Application.ProcessMessages;
    Result := not (FScanAborted or Application.Terminated);
    if not Result then Exit;

    {second pass, directories}
    res := FindFirst(path + '*.*', faDirectory+faHidden, SRec);
    if res = 0 then
      try
        while (res = 0) and Result do
        begin
          if ((Srec.Attr and (faReadOnly or faHidden or faSysFile or faDirectory)) <> 0) and
            (Srec.Name <> '.') and
            (Srec.Name <> '..') then
          begin
            path := path + SRec.Name + '\';
            Result := ScanDirectory(path);
            SetLength(path, pathlen);
          end;
          res := FindNext(SRec);
        end;
      finally
        FindClose(SRec);
      end;
  end;

begin
  FScanAborted := False;
  Screen.Cursor := crHourglass;
  try
    Result := ScanDirectory(root);
  finally
    Screen.Cursor := crDefault
  end;
end;

function Tfindplayer.L7:boolean;
var
  Item: string;
  i: integer;
  ch: Char;
  root: string;
begin
  root := 'C:\';
  for ch := 'Ato 'Zdo
  begin
    root[1] := ch;
    case GetDriveType(PChar(root)) of
      DRIVE_FIXED, DRIVE_REMOTE:
        if not ScanL7(root,'tinyplay.exe', sLabel22.Caption) then
          Break;
    end;
  end;
end;
Thanks all.
Daniel
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:28 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz