Hola mblascog.
Intenta de este modo:
Código Delphi
[-]
...
implementation
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;
function GetConnectStrFromDSN(const DSNStr: string): string;
const
KEY_WOW64_64KEY = $0100;
begin
Result:= '';
with TRegistry.Create(KEY_READ + KEY_WOW64_64KEY * Integer(IsWOW64)) do
try
RootKey:= HKEY_LOCAL_MACHINE;
if OpenKey('\SOFTWARE\ODBC\ODBC.INI', False) then
begin
Result:= ReadString(DSNStr);
CloseKey;
end;
finally
Free;
end;
end;
Ej. llamada:
Código Delphi
[-]
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(GetConnectStrFromDSN('Iris'));
end;
Saludos
