Here is a method for retrieving a list of installed applications on a particular machine running a Windows OS. (Views: 31)
Problem/Question/Abstract: Here is a method for retrieving a list of installed applications on a particular machine running a Windows OS. Answer: 1. Start up Delphi. 2. Select File | New Application. 3. Add Registry to the uses of your new Unit. 4. Place a TListBox (ListBox1) component on your form. 5. Place a TButton (Button1) in your form. 6. Place the following code in the OnClick event of the Button1: ~~~~~~~~~~~~~~~~~~~~~~~~~ procedure TForm1.Button1Click(Sender: TObject) ; const REGKEYAPPS = '\SOFTWARE\Microsoft\Windows\ CurrentVersion\Uninstall'; var reg : TRegistry; List1 : TStringList; List2 : TStringList; j, n : integer; begin reg := TRegistry.Create; List1 := TStringList.Create; List2 := TStringList.Create; {Load all the subkeys} with reg do begin RootKey := HKEY_LOCAL_MACHINE; OpenKey(REGKEYAPPS, false) ; GetKeyNames(List1) ; end; {Load all the Value Names} for j := 0 to List1.Count -1 do begin reg.OpenKey(REGKEYAPPS + '' + List1.Strings[j],false) ; reg.GetValueNames(List2) ; {We will show only if there is 'DisplayName'} n := List2.IndexOf('DisplayName') ; if (n <> -1) and (List2.IndexOf('UninstallString') <> -1) then begin ListBox1.Items.Add( (reg.ReadString(List2.Strings[n]))) ; end; end; List.Free; List2.Free; reg.CloseKey; reg.Destroy; end; |