Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   API de Windows (https://www.clubdelphi.com/foros/forumdisplay.php?f=7)
-   -   Escribir en el Registro para crear mis ODBC (https://www.clubdelphi.com/foros/showthread.php?t=75235)

JerS 06-08-2011 21:27:05

Escribir en el Registro para crear mis ODBC
 
Buenas amigos estoy tratando de crear mis odbc escribiendo esto en el registro lo he probado tanto en Windows Xp como en W7! ejecutandolo como Administrador y nada!!

Código Delphi [-]
programa:='Ruta de Archivo de Programas'
            r := TRegistry.create;
            r.RootKey:= HKEY_LOCAL_MACHINE;
            r.OpenKey('SOFTWARE\ODBC\ODBC.INI\MyODBC',true);
            r.WriteString('Database','MyBaseDatos);
            r.WriteString('Driver',programas+'\MySQL\Connector ODBC 5.1\myodbc5.dll');
            r.WriteString('PORT',Inttostr(3306));
            r.WriteString('PWD','clave');
            r.WriteString('Server','localhost');
            r.WriteString('UID','root');
            r.CloseKey;
            r.Free;
            r := TRegistry.create;
            r.RootKey:= HKEY_LOCAL_MACHINE;
            r.OpenKey('SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources',true);
            r.CloseKey;
            r.Free;
            r := TRegistry.create;
            r.RootKey:= HKEY_LOCAL_MACHINE;
            r.OpenKey('SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources',true);

si conocen una mejor forma se los agradeceria muchas gracias de antemano

juanlaplata 07-08-2011 02:49:25

Esto hago al guardar el ancho de columnas de un DBGrid,
Código Delphi [-]
Var
 Registro  : TRegistry;  
 F         : Byte; 
Begin 
Registro:=TRegistry.Create; 
Registro.OpenKey('\Software\Administrador\'+v_Empresa+'\Grids',True); 
 For F:=0 To DbGrid.Columns.Count-1 Do Registro.WriteInteger(nombForm+DbGrid.Name+'['+IntToStr(F)+']',DbGrid.Columns[F].Width); 
Registro.Free;
La unica diferencia q veo con tu codigo, es que no uso el " CloseKey; "

Uso Delphi 6 y Win Xp.
Saludos, suerte.

newtron 07-08-2011 09:24:40

Pero ¿cual es el problema? ¿no te escribe en el registro o no te conecta con la base de datos?

JerS 07-08-2011 19:47:31

Cita:

Empezado por newtron (Mensaje 408772)
Pero ¿cual es el problema? ¿no te escribe en el registro o no te conecta con la base de datos?

No escribe en el registro, no me crea los ODBC

JerS 07-08-2011 20:27:21

Listo amigos ya consegui cual era mi problema

estaba haciendo

Código Delphi [-]
 r.OpenKey('SOFTWARE\ODBC\ODBC.INI\MyOdbc',true);

y la clave no existia
entonces antes de esto
hice un

Código Delphi [-]
r.CreateKey('SOFTWARE\ODBC\ODBC.INI\MyOdbc');

y aparte de eso tambien me estaba faltando escribir

Código Delphi [-]

r := TRegistry.create;
r.RootKey:= HKEY_LOCAL_MACHINE;
r.OpenKey('SOFTWARE\ODBC\ODBC.INI\ODBC Data Sources',true);
r.WriteString('MyOdbc','MySQL ODBC 5.1 Driver');
r.CloseKey;
r.Free;

Gracias por la ayuda y espero que este aporte le sea util a cualquier otra persona


La franja horaria es GMT +2. Ahora son las 19:00:48.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi