写注册表:
Var
MyReg:TRegistry;
begin
MyReg:=TRegistry.Create(Application);
try
begin
MyReg.RootKey:=HKEY_CURRENT_USER;
//YourLinkName:你的用户自定义数据源DSN
MyReg.OpenKey(Software/ODBC/ODBC.INI/YourLinkName/',true);
MyReg.WriteString('DataBaseFile',YourDataBasePath+'MyDataBase.DB');
MyReg.WriteString('DataBaseName','YourName');
MyReg.WriteString('Description','A Test');
//此处根据你用数据库来写自己看看注册表吧!
MyReg.WriteString('Driver',YourODBCDRIVERDLLName);
MyReg.WriteString('PWD','YourPassWord');
MyReg.WriteString('UID','YourUserName');
MyReg.CloseKey;
//自定义系统DSN名为:YourLinkDRV
MyReg.OpenKey('/Software/ODBC/ODBC.INI/ODBC Data Sources/',true);
MyReg.WrriteString('YourLinkName','YourLinkDRV');
MyReg.CloseKey;
MyReg.RootKey:=HKEY_LOCAL_MACHINE;
MyReg.OpenKey('/Software/ODBC/ODBCINST.INI/YourLinkDRV',True);
//驱动程序名:YourODBCDRIVERDLLName
MyReg.WriteString('Drive',YourODBCDRIVERDLLName);
MyReg.WriteString('Setup',YourODBCDRIVERDLLName);
MyReg.CloseKey;
MyReg.OpenKey('SoftWare/ODBC/ODBCINST.INI/ODBC Drivers/',true);
MyReg.WriteString(YourODBCDRIVERDLLName,'Installed');
MyReg.CloseKey;
end;
finally
MyReg.Free;
end;
end;