Title: List of Windows installed applications
Question: List of Windows installed applications
Answer:
The list of installed applications, we can read it of the Windows registry, in the key:
'\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'
In this example, we will fill a TMemo with the names of the applications installed in Windows, and also with the names of the executables that will make their unistall.
Add 'Registry in the uses of your form
Put a TMemo (Memo1) and a TButton (Button1) in your form
Put this code in the OnClick event of Button1:
procedure TForm1.Button1Click(Sender: TObject);
const CLAVE =
'\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall';
var
reg : TRegistry;
Lista : TStringList;
Lista2 : TStringList;
i,n : integer;
begin
{Creamos cosas temporales}
{Create temporal things}
reg := TRegistry.Create;
Lista := TStringList.Create;
Lista2 := TStringList.Create;
{Cargamos todas las subkeys}
{Load all the subkeys}
with Reg do
begin
RootKey := HKEY_LOCAL_MACHINE;
OpenKey(CLAVE,false);
GetKeyNames(Lista);
end;
{Cargamos todos los Nombres de valores}
{Load all the Value Names}
for i := 0 to Lista.Count -1 do
begin
reg.OpenKey(CLAVE + '\' +Lista.Strings[i],false);
reg.GetValueNames(Lista2);
{Mostraremos slo los que tengan 'DisplayName'}
{We will show only if there is 'DisplayName'}
n:=Lista2.IndexOf('DisplayName');
if (n -1) and (Lista2.IndexOf('UninstallString')-1) then
begin
{DisplayName+UnInstallString}
Memo1.Lines.Append ( reg.ReadString(Lista2.Strings[n])+'-'+
reg.ReadString(Lista2.Strings[Lista2.IndexOf('UninstallString')]) );
end;
end;
{Liberamos temporales}
{Free temporals}
Lista.Free;
Lista2.Free;
reg.CloseKey;
reg.Destroy;
end;