DelphiFAQ Home Search:

Retrieve a list of all installed applications

 

commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.

Under Windows 95, 98, ME, NT and Windows 2000 it is common habit that applications write their installation information into the registry under

HKEY_LOCAL_MACHINE\Software\Mirosoft\Windows\CurrentVersion\UnInstall

Each application has a subkey there and at least defines a display name and an uninstall string.
On my system here I noticed that Allaire Homesite left its installation stamp in HKEY_CURRENT_USER instead of HKEY_LOCAL_MACHINE. So to be save, one might want to scan below HKEY_CURRENT_USER as well. The following sample application retrieves the installed applications and version number - feel free to use it or download it.

<p

{sc-----------------------------------------------------------------------
  
  Copyright (c) 1997-2001
  software preview

  Modified by Peter Tiemann on 2/18/2001

  Percentage of Comments/ Cyclometric Complexity Numbers by function:
  -------------------------------------------------------------------
  TForm1.FormCreate                                              9%   5

  Download
-----------------------------------------------------------------------sc}
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    procedure FormCreate(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

uses
  Registry;

{$R *.DFM}

{sc-----------------------------------------------------------------------
  Name:       TForm1.FormCreate
  Parameters:
     Sender
  Returns:
     -
  Cyclometric Complexity: 5               ,   3 comments in 32 lines = 9%

  Purpose:
    Retrieve installed apps and collect some info about them

  Date     Coder    CRC Comment
  02/18/01 Tiemann  58  Initial version!                                 
-----------------------------------------------------------------------sc}
procedure TForm1.FormCreate(Sender: TObject);
var
  aList: TStrings;
  i: Integer;
  sVersion: string;
const
  sUninstall = 'Software\Microsoft\Windows\CurrentVersion\UnInstall';
begin
  // enumerate installed applications
  aList := TStringList.Create;

  with TRegistry.Create do
  begin
    RootKey := HKEY_LOCAL_MACHINE;
    if OpenKey(sUninstall, False) then
    begin
      GetKeyNames(aList);
      CloseKey;

      for i := 0 to aList.Count - 1 do
      begin
        if OpenKey(sUninstall +
                   '\' +
                   aList[i], False) then
        begin
          // collect some info about the installed stuff
          if ValueExists('DisplayVersion') then
            sVersion := 'Version ' + ReadString('DisplayVersion')
          else
            sVersion := '';

          ListBox1.Items.Add(aList[i] + #9 + sVersion);
          CloseKey
        end;
      end;
    end;
    // free the registry object
    Free
  end;
  aList.Free
end;

end.
You don't like the formatting? Check out SourceCoder then!

Comments:

2007-09-13, 15:18:57
anonymous from Iran  
hi I can get installed programs list but i want make some thing like windows all program with installed programs icon and when i click on one of them that program start running
how i must do that?

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: