找Registry里HKEY_LOCALMACHINE\Software\ODBC参考一下ODBC每项的格式,然后仿照这些格式写一个新项就行了。
解决方案 »
- 如何让EXCEL导入SQL的数据不能有重复?
- 在SQL能否实现下列的查询结果
- 请问如何做QQ自动回复?要智能的,比如不同好友,不同回复,不同分组的、不同性别的等等,都能识别????
- 拿分啦!高分,求解决针打时走纸的办法!在线等!Up有分
- 如何让active form 界面初始化时显示一棵树
- 阻塞方式使用SocketStream通讯,帮忙啊!!!
- Delphi中调用C++中导出的成员函数问题
- 这句SQL怎么写???
- 哪有下载delphi的反编译程序?
- 还是老问题:用什么语言编程好呢?vb,vc,delphi,c++builder???
- 请问怎样把下载的控件加入到DELPHI 5里??
- chechy(chechy)快来救命! ClientDataSet1控件更新dbgrid中的数据时,执行applyupdates(-1)又出错了!!!
var
registerTemp,reg : TRegistry;
bData : array[ 0..0 ] of byte;
systemdir,appdir,ss:string;
begin
appdir:=extractfilepath(application.exename);
reg:=Tregistry.create;
with reg do
begin
RootKey:=HKEY_LOCAL_MACHINE;
if openkey('SoftWare\Microsoft\Windows\CurrentVersion',false) then
ss:=ReadString('devicepath');
end;
systemdir:=copy(ss,0,length(ss)-4);
reg.free;
registerTemp := TRegistry.Create; //建立一个Registry实例
with registerTemp do
begin
RootKey:=HKEY_LOCAL_MACHINE;//设置根键值为HKEY_LOCAL_MACHINE
//找到Software\ODBC\ODBC.INI\ODBC Data Sources
if not KeyExists('Software\ODBC\ODBC.INI\SJTZ\') then
begin
if OpenKey('Software\ODBC\ODBC.INI\ODBC Data Sources',True) then
begin //注册一个DSN名称
WriteString( 'SJTZ', 'Microsoft Access Driver (*.mdb)' );
end
else
begin//创建键值失败
showmessage('增加ODBC数据源失败');
exit;
end;
CloseKey;
//找到或创建Software\ODBC\ODBC.INI\sjtz,写入DSN配置信息
if OpenKey('Software\ODBC\ODBC.INI\SJTZ',True) then
begin
WriteString( 'DBQ', appdir+'dataass\sjtz.mdb');//数据库目录
WriteString( 'Description', '审计台帐管理系统');//数据源描述
WriteString( 'Driver', systemdir+'\odbcjt32.dll');//驱动程序DLL文件
WriteInteger( 'DriverId', 25);//驱动程序标识
WriteString( 'FIL', 'Ms Access;');//Filter依据
WriteInteger( 'SafeTransaction', 0 );//支持的事务操作数目
WriteString( 'UID', '' );//用户名称
bData[0] := 0;
//WriteBinaryData( 'Exclusive', bData, 1 );//非独占方式
//WriteBinaryData( 'ReadOnly', bData, 1 );//非只读方式
end
else//创建键值失败
begin
showmessage('增加ODBC数据源失败');
exit;
end;
CloseKey; //找到或创建Software\ODBC\ODBC.INI\MyAccess\Engines\Jet
//写入DSN数据库引擎配置信息
if OpenKey('Software\ODBC\ODBC.INI\SJTZ\Engines\Jet',True) then
begin
WriteString( 'ImplicitCommitSync', '' );
WriteInteger( 'MaxBufferSize', 2048 );//缓冲区大小
WriteInteger( 'PageTimeout', 5 );//页超时
WriteInteger( 'Threads', 3 );//支持的线程数目
WriteString( 'UserCommitSync', 'Yes' );
end
else//创建键值失败
begin
showmessage('增加ODBC数据源失败');
exit;
end;
CloseKey;
end;
//('增加新ODBC数据源成功');
Free;
end;
end;