Lister les logiciels installés sur le système

procedure TForm1.Button1Click(Sender: TObject);
const
UNINST_PATH = 'SOFTWAREMicrosoftWindowsCurrentVersionUninstall';
var
Reg: TRegistry;
SubKeys: TStringList;
ListItem: TlistItem;
i: integer;
sDisplayName, sUninstallString: string;
begin
{ ListView1.ViewStyle := vsReport;
ListView1.Columns.add;
ListView1.Columns.add;
ListView1.Columns[0].caption := 'DisplayName';
ListView1.Columns[1].caption := 'UninstallString';
ListView1.Columns[0].Width := 300;
ListView1.Columns[1].Width := 300;}
Reg := TRegistry.Create;
with Reg do
try
with ListView1.items do
try
BeginUpdate;
Clear;
RootKey := HKEY_LOCAL_MACHINE;
if OpenKeyReadOnly(UNINST_PATH) then
begin
SubKeys := TStringList.Create;
try
GetKeyNames(SubKeys);
CloseKey;
for i := 0 to subKeys.Count - 1 do
if OpenKeyReadOnly(Format('%s\%s', [UNINST_PATH, SubKeys[i]])) then
try
sDisplayName := ReadString('DisplayName');
sUninstallString := ReadString('UninstallString');
if sDisplayName <> '' then
begin
ListItem := add;
ListItem.Caption := sDisplayName;
ListItem.subitems.add(sUninstallString);
end;
finally
CloseKey;
end;
finally
SubKeys.Free;
end;
end;
finally
ListView1.AlphaSort;
EndUpdate;
end;
finally
closekey;
Free;
end;
end;
Ajouter un commentaire
Pseudo
Adresse email
Site internet (optionnel)
Votre commentaire
Fiche de l'article
Mise a jour28/11/2001
VisualisationVu 677 fois
PublicInternaute zz
CategorieDelphi - Trucs et astuces - Systeme
Auteur de l'article
arachnosoft arachnosoft
connecté le 02/11/2011
1 articles dans la section
Contacter l'auteur