?
Solved

Adding a List of installed applications to a listbox

Posted on 2007-08-05
2
Medium Priority
?
137 Views
Last Modified: 2010-04-05
I need to add a list on a listbox of all installed applications.

Path+exename

Is there anyway to do this please?

Thanks

ST3VO
0
Comment
Question by:ST3VO
2 Comments
 
LVL 9

Accepted Solution

by:
sas13 earned 2000 total points
ID: 19634956
read HKLM\Software\Microsoft\Windows\CurrentVersion\App Paths registry key

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses
  Registry, ComObj;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  _i: integer;
  _list: TStringList;
  _file: string;
const
  BASEKEY = 'Software\Microsoft\Windows\CurrentVersion\App Paths';
begin
 with TRegistry.Create do
  try
   RootKey := HKEY_LOCAL_MACHINE;
   if OpenKeyReadOnly(BASEKEY) then begin
    _list := TStringList.Create;
    ListBox1.Items.BeginUpdate;
    ListBox1.Items.Clear;
    try
     GetKeyNames(_list);
     for _i := 0 to _list.Count-1 do begin
      CloseKey;
      if OpenKeyReadOnly(BASEKEY+'\'+_list[_i]) then begin
       _file := ReadString(EmptyStr);   // default
       if FileExists(_file) and (Pos('.exe', LowerCase(_file)) > 0) then begin
        ListBox1.Items.Add(_file);
        Continue
       end;
       _file := IncludeTrailingBackslash(_file)+_list[_i];
       if FileExists(_file) and (Pos('.exe', LowerCase(_file)) > 0) then begin
        ListBox1.Items.Add(_file);
        Continue
       end;
       if ValueExists('path') then begin
        _file := IncludeTrailingBackslash(ReadString('path'))+_list[_i];
        if FileExists(_file) and (Pos('.exe', LowerCase(_file)) > 0) then begin
         ListBox1.Items.Add(_file);
         Continue
        end
       end
      end
     end
    finally
     ListBox1.Items.EndUpdate;
     _list.Free
    end
   end
  finally
   Free
  end
end;

end.
0
 

Author Comment

by:ST3VO
ID: 19635331
Perfect!!!

Thanks a million :o)

-ST3VO
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This is an update to some code that someone else posted on Experts Exchange. It is an alternate approach, I think a little easier to use, & makes sure that things like the Task Bar will update.
Planning to migrate your EDB file(s) to a new or an existing Outlook PST file? This video will guide you how to convert EDB file(s) to PST. Besides this, it also describes, how one can easily search any item(s) from multiple folders or mailboxes…
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
Suggested Courses

589 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question