1 2 {3 The installed software information is stored in the Registry.4 5 Installed on All Users6 Rootkey : HKEY_LOCAL_MACHINE7 Path : SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall8 9 Installed on Current User10 Rootkey : HKEY_CURRENT_USER11 Path : SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall12 13 DisplayName is the title of the program.14 UnistallString is the path used for uninstallation of the software.15 If DisplayName and UnistallString exists it is a installet program.16 }17 18 //This example shows how to get the installet software for all users.19 unit Unit1;
20 21 interface22 23 uses24 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
25 Dialogs, StdCtrls,Registry;
26 27 type28 TForm1 = class(TForm)
29 ListBox1: TListBox;
30 Button1: TButton;
31 procedure Button1Click(Sender: TObject);
32 private33 { Private declarations }34 public35 { Public declarations }36 end;
37 38 var39 Form1: TForm1;
40 41 implementation42 43 {$R *.dfm}44 45 procedure TForm1.Button1Click(Sender: TObject);
46 var47 Reg : TRegistry;
48 Keys : TStringlist;
49 I : Integer;
50 begin51 Keys := TStringlist.Create;
52 Reg := TRegistry.Create;
53 { Change the rootkey to HKEY_CURRENT_USER to get the installed software for the 54 current user.}55 Reg.RootKey := HKEY_LOCAL_MACHINE;
56 Reg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', False);
57 Reg.GetKeyNames(Keys);
58 Reg.CloseKey;
59 for I := 0 to Keys.Count-1 do60 begin61 if62 Reg.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\'+Keys.Strings[I],
63 false) then64 begin65 if Reg.ValueExists('DisplayName') and Reg.ValueExists('UninstallString')
66 then67 ListBox1.Items.Add(Reg.ReadString('DisplayName')+' |
68 'Reg.ReadString('UninstallString'));
69 Reg.CloseKey;
70 end;
71 end;
72 Reg.Free;
73 Keys.Free;
74 end;
75 76 77 end.
78