PDA

Ver la Versión Completa : Guardar todas las claves de registro en INNOSETUP


teecweb
13-03-2013, 01:23:36
Holas , quisiera guardar todas las claves del registro de esta ruta
'\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall'

guardarlo en una lista y despues recorrerlo preguntando por su displayName

Aqui les dejo un codigo en delphi pero yo quisiera hacerlo en innosetup ya que el codigo cambia un poco

gracias por su respuestas..:D


procedure ListarAplicaciones( Lista: TListBox );
const
INSTALADOS = '\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall';
var
Registro: TRegistry;
Lista1 : TStringList;
Lista2 : TStringList;
j, n : integer;
begin
Registro := TRegistry.Create;
Lista1 := TStringList.Create;
Lista2 := TStringList.Create;

// Guardamos todas las claves en la lista 1
with Registro do
begin
RootKey := HKEY_LOCAL_MACHINE;
OpenKey( INSTALADOS, False );
GetKeyNames( Lista1 );
end;

// Recorremos la lista 1 y leemos el nombre del programa instalado
for j := 0 to Lista1.Count-1 do
begin
Registro.OpenKey( INSTALADOS + '\' + Lista1.Strings[j], False );
Registro.GetValueNames( Lista2 );

// Mostramos el programa instalado sólo si tiene DisplayName
n := Lista2.IndexOf( 'DisplayName' );
if ( n <> -1 ) and ( Lista2.IndexOf('UninstallString') <> -1 ) then
Lista.Items.Add( ( Registro.ReadString( Lista2.Strings[n] ) ) );
end;

Lista.Sorted := True; // Ordenamos la lista alfabéticamente
Lista1.Free;
Lista2.Free;
Registro.CloseKey;
Registro.Destroy;
end;

maeyanes
13-03-2013, 15:54:09
Hola...

Lo que tienes que haces es usar arreglos de string para obtener la lista de subkeys con la función RegGetSubkeyNames y el valor de DisplayName usando la función RegQueryStringValue, la misma ayuda de InnoSetup tiene ejemplos.


const
UninstallKey = '\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall';
var
Installed: TArrayOfString;
I: Integer;
AppName: string;
AppNameList: TStringList;

begin
if RegGetSubkeyNames(HKEY_LOCAL_MACHINE, UninstallKey, Installed) then
begin
AppNameList := TStringList.Create;
AppNameList.Sorted := True;
for I := 0 to GetArrayLength(Installed) do
if RegQueryStringValue(HKEY_LOCAL_MACHINE, UninstallKey + '\' + Installed[I], 'DisplayName', AppName) and (AppName <> '') then
AppNameList.Add(AppName)
end
end;




Saludos...

teecweb
13-03-2013, 16:05:29
gracias ..ya lei la ayuda y encontre la funcion..y justamente coincidimos con la respuestas..igualemnte gracias