Einzelnen Beitrag anzeigen

Benutzerbild von turboPASCAL
turboPASCAL

Registriert seit: 8. Mai 2005
Ort: Sondershausen
4.274 Beiträge
 
Delphi 6 Personal
 
#7

AW: Liste aller installierten Programme

  Alt 26. Jun 2011, 11:56
Oder so etwas ?

Delphi-Quellcode:
function GetWinAppInstallInfo(outStrings: TStrings): bool;
const
  REG_APPPATHS = '\Software\Microsoft\Windows\CurrentVersion\Uninstall';
var
  AppInfo: string;
  strLst: TStringList;
  i: Integer;
begin
  Result := False;

  if ASSIGNED(outStrings) then
  begin
    with TRegistry.Create(KEY_READ) do
    try
      RootKey := HKEY_LOCAL_MACHINE;

      strLst := TStringList.Create;
      try
        if OpenKey(REG_APPPATHS, False) then
        begin
          GetKeyNames(strLst);
          CloseKey;

          for I := 0 to strLst.Count - 1 do
          begin
            outStrings.Add(format('Application: %s', [strLst[I]]));
            if OpenKey(REG_APPPATHS + '\' + strLst[I], False) then
            begin
              AppInfo := #9'Location:';
              if ValueExists('InstallLocation')
                then AppInfo := AppInfo + #9#9 + ReadString('InstallLocation') + #13#10
                else AppInfo := AppInfo + #9#9'(System)' + #13#10;

              if ValueExists('Displayname') then
                AppInfo := AppInfo + #9'Displayname: ' + #9 + ReadString('Displayname') + #13#10;

              outStrings.Add(AppInfo);
              CloseKey;

              Result := True;
            end;
          end; //for
        end else
        begin
          // Error read
        end;
      finally
        strLst.Free;
      end;
    finally
      Free; // Registry
    end;
  end else
    ShowMessage('Zonk "outStrings" !');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Memo1.Clear;
  GetWinAppInstallInfo(Memo1.Lines);
end;
Matti
Meine Software-Projekte - Homepage - Grüße vom Rüsselmops -Mops Mopser
  Mit Zitat antworten Zitat