Author: Michael Britt
Here is a method for retrieving a list of installed applications on a particular
machine running a Windows OS.
Answer:
Start up Delphi.
Select File | New Application.
Add Registry to the uses of your new Unit.
Place a TListBox (ListBox1) component on your form.
Place a TButton (Button1) in your form.
Place the following code in the OnClick event of the Button1:
1 procedure TForm1.Button1Click(Sender: TObject);
2 const3 REGKEYAPPS = '\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall';
4 5 var6 reg: TRegistry;
7 List1: TStringList;
8 List2: TStringList;
9 j, n: integer;
10 11 begin12 reg := TRegistry.Create;
13 List1 := TStringList.Create;
14 List2 := TStringList.Create;
15 16 {Load all the subkeys}17 with reg do18 begin19 RootKey := HKEY_LOCAL_MACHINE;
20 OpenKey(REGKEYAPPS, false);
21 GetKeyNames(List1);
22 end;
23 {Load all the Value Names}24 for j := 0 to List1.Count - 1 do25 begin26 reg.OpenKey(REGKEYAPPS + '' + List1.Strings[j], false);
27 reg.GetValueNames(List2);
28 29 {We will show only if there is 'DisplayName'}30 n := List2.IndexOf('DisplayName');
31 if (n <> -1) and32 (List2.IndexOf('UninstallString') <> -1) then33 begin34 ListBox1.Items.Add(
35 (reg.ReadString(List2.Strings[n])));
36 end;
37 end;
38 List1.Free;
39 List2.Free;
40 reg.CloseKey;
41 reg.Destroy;
42 end;