(Gast)
n/a Beiträge
|
AW: Liste der Exe-Pfade aller installierten Programme
4. Jan 2013, 01:52
Delphi-Quellcode:
procedure GetFiles(Path, ExtMask: String; List: TStrings; SubFolder: Boolean);
const
Attrib = faArchive or faReadOnly or faHidden;
var
Tmp: String;
k: Integer;
Search: TSearchRec;
begin
Path := IncludeTrailingBackslash(Path);
with TStringList.Create do
try
CommaText := ExtMask;
for k := 0 to Count - 1 do
begin
Tmp := Strings[k]; //Entfernt führenden Punkt vor der Ext
while Copy(Tmp, 1, 1) = '.' do System.Delete(Tmp, 1, 1);
Strings[k] := Tmp;
if FindFirst(Path + '*.' + Strings[k], Attrib, Search) = 0 then
repeat
if List.IndexOf(Path + Search.Name) < 0 then //Doppelte Filtern
List.Add(Path + Search.Name);
until FindNext(Search) <> 0;
end;
FindClose(Search);
finally Free end;
//----------------------------------------------------------------------------
//Application.ProcessMessages;
if SubFolder then
begin
if FindFirst(Path + '*.*', faDirectory, Search) = 0 then
begin
repeat
if ((Search.Attr and faDirectory) = faDirectory) and
(Search.Name[1] <> '.') then
GetFiles(Path + Search.Name, ExtMask, List, SubFolder);
until FindNext(Search) <> 0;
FindClose(Search);
end;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
GetFiles('c:\', 'exe', ListBox1.Items, True);
end;
Ansonsten die Frage genauer stellen.
|
|
Zitat
|