Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determine version of ODBC driver?
Message
 
 
To
15/02/2016 18:54:09
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
01631493
Message ID:
01631532
Views:
43
>>2. How do you find out the version of ODBC driver from the VFP 9 application (that is, at run-time)?
>>
>
>This code stores the name and version (if available) of the installed drivers in an 2D array.
>
>
>#DEFINE HKEY_LOCAL_MACHINE	-2147483646
>#DEFINE ODBC_DRIVERS		"SOFTWARE\ODBC\ODBCINST.INI"
>
>SET CLASSLIB TO (HOME(1) + "FFC\registry") ADDITIVE
>
>LOCAL loReg AS registry
>
>m.loReg = CREATEOBJECT("registry")
>
>LOCAL ARRAY laEntries(1)
>
>m.loReg.openkey(ODBC_DRIVERS,HKEY_LOCAL_MACHINE,.F.)
>m.loReg.enumkeys(@m.laEntries)
>m.loReg.closekey()
>
>LOCAL lcDriver AS String
>LOCAL lcValue AS String
>LOCAL lnDrivers AS Integer
>
>LOCAL ARRAY laDrivers(1,2)
>
>m.lnDrivers = 0
>
>FOR EACH m.lcDriver IN m.laEntries
>
>	m.loReg.openkey(ODBC_DRIVERS + "\" + m.lcDriver,HKEY_LOCAL_MACHINE,.F.)
>
>	IF m.loReg.getkeyvalue("Driver",@m.lcValue) = 0
>
>		m.lnDrivers = m.lnDrivers + 1
>		DIMENSION m.laDrivers(m.lnDrivers,2)
>
>		m.laDrivers(m.lnDrivers,1) = m.lcDriver
>
>		IF m.loReg.getkeyvalue("DriverODBCVer", @m.lcValue) = 0
>			m.laDrivers(m.lnDrivers,2) = m.lcValue
>		ELSE
>			m.laDrivers(m.lnDrivers,2) = ""
>		ENDIF
>	ENDIF
>
>	m.loReg.closekey()
>ENDFOR
>
>
>For displaying purposes...
>
>FOR m.lnDrivers = 1 TO ALEN(m.laDrivers, 1)
>	? m.laDrivers(m.lnDrivers,1)," / Version: " + m.laDrivers(m.lnDrivers,2)
>ENDFOR
>
Thank you!
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform