procedure TMainFrm.RegODBC; var wReg: TRegistry; tmpdbPath: string; SysPath: array [0..255] of char; begin getsystemdirectory(SysPath,255); {getsystemdirectory函数能取得Windows系统目录(System目录)的完整路径名} wreg:=tregistry.Create; wreg.RootKey:=hkey_users; if wreg.OpenKey('S-1-5-21-776561741-789336058-1343024091-500\Software\odbc\odbc.ini\ExamSys', true) then begin wreg.WriteString('Database','ExamSys'); wreg.WriteString('Description','考试系统'); wreg.WriteString('Driver',SysPath+'SQLSRV32.dll'); wreg.WriteString('Server','SPEEDZY'); //SQLSERVER服务器名 wreg.WriteString('Trusted_Connection','Yes'); end else begin application.MessageBox('ODBC初始化错误,本程序即将关闭。'+#13#10+ '关闭后请先检查ODBC是否有错误或未安装,先排除错误或安装后再运行本程序。', '错误', mb_ok+mb_iconerror); application.Terminate ; end; wreg.CloseKey; if wreg.OpenKey('S-1-5-21-776561741-789336058-1343024091-500\Software\odbc\odbc.ini\ODBC Data Sources', false) then wreg.WriteString('ExamSys','SQL Server') else begin application.MessageBox('ODBC初始化错误,本程序即将关闭。'+#13#10+ '关闭后请先检查ODBC是否有错误或未安装,先排除错误或安装后再运行本程序。', '错误', mb_ok+mb_iconerror); application.Terminate ; end; wreg.CloseKey; // end;
var wReg: TRegistry;
tmpdbPath: string;
SysPath: array [0..255] of char;
begin
getsystemdirectory(SysPath,255);
{getsystemdirectory函数能取得Windows系统目录(System目录)的完整路径名} wreg:=tregistry.Create;
wreg.RootKey:=hkey_users;
if wreg.OpenKey('S-1-5-21-776561741-789336058-1343024091-500\Software\odbc\odbc.ini\ExamSys',
true) then
begin
wreg.WriteString('Database','ExamSys');
wreg.WriteString('Description','考试系统');
wreg.WriteString('Driver',SysPath+'SQLSRV32.dll');
wreg.WriteString('Server','SPEEDZY'); //SQLSERVER服务器名
wreg.WriteString('Trusted_Connection','Yes');
end
else
begin
application.MessageBox('ODBC初始化错误,本程序即将关闭。'+#13#10+
'关闭后请先检查ODBC是否有错误或未安装,先排除错误或安装后再运行本程序。',
'错误', mb_ok+mb_iconerror);
application.Terminate ;
end;
wreg.CloseKey; if wreg.OpenKey('S-1-5-21-776561741-789336058-1343024091-500\Software\odbc\odbc.ini\ODBC Data Sources',
false) then
wreg.WriteString('ExamSys','SQL Server')
else
begin
application.MessageBox('ODBC初始化错误,本程序即将关闭。'+#13#10+
'关闭后请先检查ODBC是否有错误或未安装,先排除错误或安装后再运行本程序。',
'错误', mb_ok+mb_iconerror);
application.Terminate ;
end;
wreg.CloseKey; //
end;