FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour obtain ODBC drivers installed
Posts: 1303
Joined: Tue Jul 21, 2009 08:12 AM
obtain ODBC drivers installed
Posted: Sat Jun 15, 2013 09:17 AM

Hello,

Is it possible to obtain them, so I can check, for example, that MySQL ODBC is installed or not at ODBC system?.

Thank you very much.

Best regards

Muchas gracias. Many thanks.



Un saludo, Best regards,



Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]



Implementando MSVC 2010, FWH64 y ADO.



Abandonando uso xHarbour y SQLRDD.
Posts: 1335
Joined: Fri Jun 13, 2008 11:04 AM
Re: obtain ODBC drivers installed
Posted: Sat Jun 15, 2013 10:34 AM
Code (fw): Select all Collapse
if !CheckMySQL_ODBC_Status('MySQL ODBC 5.2a Driver')  // ODBC Driver installed or not
    MsgInfo("MySQL ODBC 5.2a Driver is not installed in this PC")
    Return NIL
Endif


*-----------------------------------*
Function CheckMySQL_ODBC_Status(cDriver)
*-----------------------------------*
    // cDriver can be either 'MySQL ODBC 3.51 Driver' OR 'MySQL ODBC 5.1 Driver'
    Local oReg,cStatus,lStatus:=.F.
    
    oReg  := TReg32():New( HKEY_LOCAL_MACHINE, "SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers" )
    cStatus:=""           
    cStatus:= oReg:Get( cDriver, cStatus ) // If installed cStatus would have a value "Installed" else empty
    oReg:Close()
    lStatus:=iif( cStatus == "Installed",.T.,.F.)

Return lStatus


Regards
Anser
Posts: 1195
Joined: Mon Oct 17, 2005 05:41 AM
Re: obtain ODBC drivers installed
Posted: Sat Jun 15, 2013 03:30 PM
anserkk wrote:
Code (fw): Select all Collapse
if !CheckMySQL_ODBC_Status('MySQL ODBC 5.2a Driver')  // ODBC Driver installed or not
    MsgInfo("MySQL ODBC 5.2a Driver is not installed in this PC")
    Return NIL
Endif


*-----------------------------------*
Function CheckMySQL_ODBC_Status(cDriver)
*-----------------------------------*
    // cDriver can be either 'MySQL ODBC 3.51 Driver' OR 'MySQL ODBC 5.1 Driver'
    Local oReg,cStatus,lStatus:=.F.
    
    oReg  := TReg32():New( HKEY_LOCAL_MACHINE, "SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers" )
    cStatus:=""           
    cStatus:= oReg:Get( cDriver, cStatus ) // If installed cStatus would have a value "Installed" else empty
    oReg:Close()
    lStatus:=iif( cStatus == "Installed",.T.,.F.)

Return lStatus


Regards
Anser


Thanks Anser,

I notice than on a 64bit PC you need use this key.
Code (fw): Select all Collapse
oReg  := TReg32():New( HKEY_LOCAL_MACHINE, "SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\ODBC Drivers" )
Regards,

Marc



FWH32+xHarbour | FWH64+Harbour | BCC | DBF | ADO+MySQL | ADO+MariaDB | ADO+SQLite
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: obtain ODBC drivers installed
Posted: Mon Jun 17, 2013 01:44 AM

When we make a generic application/library can we assume every user can access registry? It is common that many net work administrators severely restrict rights of network users.

Regards



G. N. Rao.

Hyderabad, India
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: obtain ODBC drivers installed
Posted: Mon Jun 17, 2013 02:22 AM
Rao,

When we make a generic application/library can we assume every user can access registry? It is common that many net work administrators severely restrict rights of network users.


But can't all programs read the registry? It seems that most programs need to be able to do this. It would be a problem if only the programs administrators were using could.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: obtain ODBC drivers installed
Posted: Mon Jun 17, 2013 03:09 AM
But can't all programs read the registry? It seems that most programs need to be able to do this. It would be a problem if only the programs administrators were using could.

Not administrators only. Normally all users can read, unless access is restricted. I know of many corporate networks where the network administrators are so conservative to restrict access severely. Personally I disagree with such undue and unnecessary over-cautious approach, but our scope is limited to providing something which works even in such environments.

Well we always have this TRY/CATCH approach even to deal with such situations. :-) So we can first try accessing registry, which will succeed in a great majority of the cases and if not we always have fall back options.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1303
Joined: Tue Jul 21, 2009 08:12 AM
Re: obtain ODBC drivers installed
Posted: Mon Jun 17, 2013 07:40 AM

Hi,

Thank you for your great advice.

Best regards

Muchas gracias. Many thanks.



Un saludo, Best regards,



Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]



Implementando MSVC 2010, FWH64 y ADO.



Abandonando uso xHarbour y SQLRDD.

Continue the discussion