如题,有没有什么办法检查某个odbc驱动是否按转并得到相关的信息
比如说,是否安装了mysql odbc 5.0, 或者说得到已经安装了的odbc驱动列表并得到相关信息,比如说版本号最好不要用数据库控件尝试连接失败得到结果
而是比如说在注册表里找到相关信息?
比如说,是否安装了mysql odbc 5.0, 或者说得到已经安装了的odbc驱动列表并得到相关信息,比如说版本号最好不要用数据库控件尝试连接失败得到结果
而是比如说在注册表里找到相关信息?
解决方案 »
- 在线请教:ScrollWindowEx 为啥总有几次不成功!?
- 怎么对所选择的文本文件内容进行查询,修改等操作?
- delphi子线程向主线程发送消息,主线程使用VCL控件显示的问题。
- 我想问一个关于日期的问题
- 小女子求大家了,如何用Dephi写刻录光盘的程序,在线等,,,,
- 请教一个数据录入的问题
- 哪里可以下载最新的MySQL dbExpress驱动?
- ~~~~~~~~~~如何根据类名称创建对象~~~~~~~~~~
- 查询所有符合 表a中的一个字段=表b中的一个字段的子串的SQL语句怎么写?
- 恭喜发财!龙马精神!过年了!:)~~~~~~
- windows已经阻止此软件因为无法验证发行者
- 有关ADOQuery问题
////////////////////////////////////////////////////////////////////////////////
// //
// CheckMyODBCDriver //
// ----------------- //
// //
// Checks installation of the MyODBC driver //
// //
// Input: //
// (none) //
// //
// Result [Byte]: //
// 0: MySQL driver installed //
// 1: missing registry values //
// 2: missing file myodbc.dll //
// //
////////////////////////////////////////////////////////////////////////////////
function CheckMyODBCDriver: Byte;
var fReg: tRegistry;
bDriversValue, bMySQLKey, bMySQLValues: Boolean;
sDriver, sSetup: String;
begin
// checking the registry
try
fReg := TRegistry.Create;
fReg.RootKey := HKEY_LOCAL_MACHINE; // checking key entry \Software\ODBC\ODBCINST.INI\ODBC Drivers
fReg.OpenKey( '\Software\ODBC\ODBCINST.INI\ODBC Drivers', True );
bDriversValue := fReg.ValueExists( 'MySQL' ) and
( fReg.ReadString( 'MySQL' ) = 'Installed' ); // checking key entry \Software\ODBC\ODBCINST.INI\MySQL
bMySQLKey := fReg.KeyExists( '\Software\ODBC\ODBCINST.INI\MySQL' ); // if exists key entry \Software\ODBC\ODBCINST.INI\MySQL
// check also the values
if bMySQLKey then
begin
fReg.OpenKey( '\Software\ODBC\ODBCINST.INI\MySQL', True );
bMySQLValues := fReg.ValueExists( 'APILevel' ) and
fReg.ValueExists( 'ConnectFunctions' ) and
fReg.ValueExists( 'Driver' ) and
fReg.ValueExists( 'DriverODBCVer' ) and
fReg.ValueExists( 'FileExtns' ) and
fReg.ValueExists( 'FileUsage' ) and
fReg.ValueExists( 'Setup' ) and
fReg.ValueExists( 'SQLLevel' ); if bMySQLValues then
begin
sDriver := Trim( fReg.ReadString( 'Driver' ) );
sSetup := Trim( fReg.ReadString( 'Setup' ) );
end;
end
else
bMySQLValues := False; if ( bDriversValue and bMySQLKey and bMySQLValues ) then Result := 0
else Result := 1;
fReg.CloseKey;
fReg.Free;
except
Result := 1;
fReg.Free;
Exit;
end; // if registry entries OK => check driver files ...
if ( Result = 0 ) then
begin
if not ( FileExists( sDriver ) and FileExists( sSetup ) ) then Result := 2; end; end;
//------------------------Function SQLGetPrivateProfileString (
lpszSection :pansichar;
lpszEntry:pansichar;
lpszDefault:pansichar;
RetBuffer:pansichar;
cbRetBuffer:integer;
lpszFilename:pansichar)
:integer;stdcall;external 'ODBCCP32.DLL';
rocedure TForm1.Button1Click(Sender: TObject);
var
sqBuffer:ansipchar;
len:integer;
begin
getmem(sqBuffer,1024);
len:=SQLGetPrivateProfileString ('MySQL ODBC 5.1 Driver',nil,'', sqBuffer,1024,'odbcinst.ini');
if len<>0 then
ShowMessage('MySQL ODBC 5.1 Driver 驱动已安装!')
else
ShowMessage('MySQL ODBC 5.1 Driver驱动未安装!');
freeMem(sqBuffer);
end;