Para isso vamos precisar de um TButton e um TListView.
Inicialmente vamos precisar declarar Uses em Registry.
Não se preocupe com a configuração do TListView, pois isso será feito através do código listado logo abaixo.
No evento onClick do TButton implemente o seguinte código.
Listagem 1: Implementação no onClick do TButton
procedure TForm1.Button1Click(Sender: TObject);
const
UNINST_PATH = 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall';
var
Registro: TRegistry;
Chaves: TStringList;
xListItem: TlistItem;
I: integer;
xNomeSoftware, xCaminhoRemover: string;
begin
ListView1.ViewStyle := vsReport;
ListView1.Columns.add;
ListView1.Columns.add;
ListView1.Columns[0].caption := 'Nome do Programa';
ListView1.Columns[1].caption := 'Caminho pra Remover';
ListView1.Columns[0].Width := 300;
ListView1.Columns[1].Width := 300;
Registro := TRegistry.Create;
with Registro do
try
with ListView1.Items do
try
BeginUpdate;
Clear;
RootKey := HKEY_LOCAL_MACHINE;
if OpenKeyReadOnly(UNINST_PATH) then
begin
Chaves := TStringList.Create;
try
GetKeyNames(Chaves);
CloseKey;
for I := 0 to Chaves.Count - 1 do
if OpenKeyReadOnly(Format('%s\%s', [UNINST_PATH, Chaves[I]])) then
try
xNomeSoftware := ReadString('DisplayName');
xCaminhoRemover := ReadString('UninstallString');
if xNomeSoftware <> '' then
begin
xListItem := Add;
xListItem.Caption := xNomeSoftware;
xListItem.subitems.Add(xCaminhoRemover);
end;
finally
CloseKey;
end;
finally
Chaves.Free;
end;
end;
finally
ListView1.AlphaSort;
EndUpdate;
end;
finally
CloseKey;
Free;
end;
Veja o Resultado
Fico por aqui e até o próximo artigo
Um abraço
Wesley Y
www.lithic.com.br