Retrieving version of VFP OLE DB provider

A version of VFP OLE DB provider installed on computer can be retrieved from provider itself or from its DLL through the registry.

This is sample code. Add error handling and adjust to your requirements as necessary.

1
2
3
4
5
6
7
8
9
* From provider
loConn = CREATEOBJECT("ADODB.Connection")
lcPath = _vfp.DefaultFilePath
loConn.ConnectionString = "Provider=VFPOLEDB.1;Data Source=" + lcPath 
loConn.Open()
lcVersion = loConn.Properties("Provider version").value 
loConn.Close()
? lcVersion

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
* Through the registry
#DEFINE HKEY_CLASSES_ROOT -2147483648
* Uses Registry class from west-wind.com/wwvfppd.htm
loReg = NEWOBJECT("Registry", "registry.prg")
* Get CLSID for VFPOLEDB
lcCLSID = loReg.readregistrystring(HKEY_CLASSES_ROOT, "vfpoledb.1\CLSID", "")
IF ISNULL(lcCLSID) 
	* VFPOLEDB provider isn't installed/registered
	RETURN .F.
ENDIF
* Get full DLL name	
lcDllFullName = loReg.readregistrystring(HKEY_CLASSES_ROOT, ;
					"CLSID\" + lcCLSID + "\InprocServer32", "")	
DIMENSION laInfo[1]
* Extract version info
= AGETFILEVERSION(laInfo, lcDllFullName)
lcVersion = laInfo[4]
? lcVersion


The registry class can be downloaded from http://berezniker.com/files/registry.zip

Comments