Ver Mensaje Individual
  #9  
Antiguo 09-06-2015
Avatar de ecfisa
ecfisa ecfisa is offline
Moderador
 
Registrado: dic 2005
Ubicación: Tres Arroyos, Argentina
Posts: 10.508
Reputación: 36
ecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to beholdecfisa is a splendid one to behold
Hola cipce22.

Podríamos hacer que previemente el procedimiento detecte si estamos en Windows 32 o 64 bits para luego leer la clave correcta:
Código Delphi [-]
uses Registry;

function IsWOW64: Boolean;
type
  LPFN_ISWOW64PROCESS = function(hProcess: THandle; var Wow64Process: BOOL): BOOL; stdcall;
var
  fnIsWow64Process: LPFN_ISWOW64PROCESS;
  bIsWOW64: BOOL;
begin
  Result:= False;
  fnIsWow64Process:= LPFN_ISWOW64PROCESS(
    GetProcAddress( GetModuleHandle('kernel32'), 'IsWow64Process') );
  if Assigned( fnIsWow64Process ) then
  begin
    bIsWow64:= False;
    if fnIsWow64Process(GetCurrentProcess(), bIsWOW64) then
      Result:= bIsWOW64;
  end;
end;

procedure GetFirebirdAliases(Strings: TStrings);
const
  KEY_WOW64_64KEY = $0100;
  RKEYS: array[Boolean] of string = (
    '\Software\Firebird Project\Firebird Server\Instances',   // Windows 32
    '\SOFTWARE\WOW6432node\Firebird Project\Firebird Server\Instances' ); // Windows 64 (*)
   
var
  path: string;
  i  : Integer;
  Reg: TRegistry;
  W64: Boolean;
begin
  W64 := isWOW64;
  with TRegistry.Create(KEY_READ + KEY_WOW64_64KEY * Integer(W64)) do
  try
   RootKey := HKEY_LOCAL_MACHINE;
   if OpenKeyReadOnly(RKEYS[W64]) then
     path := ReadString('DefaultInstance');
     Strings.LoadFromFile(path + 'aliases.conf');
     for i:= Strings.Count-1 downto 0 do
      if Pos('#', Trim(Strings[i])) = 1 then
        Strings.Delete(i);
  finally
   Free;
  end;
end;
(*) No tengo Windows 64 bits en este momento como para comprobar el valor de la clave en esa versión.
Aunque si interpreté bién lo escrito en este enlace, Registry Redirector, debería ser ese.

Tendrías que usar el regedit para controlar si el valor de clave "\SOFTWARE\WOW6432node\Firebird Project\Firebird Server\Instances" es el correcto.

Saludos
__________________
Daniel Didriksen

Guía de estilo - Uso de las etiquetas - La otra guía de estilo ....
Responder Con Cita