GetMdacVersion - Retrieve the installed MDAC version
' Retrieve the installed MDAC version
'
' Examples:
' Dim ver As Version = GetMdacVersion()
' ' print the full version
' MessageBox.Show(ver.ToString())
' ' print the major and minor portions
' MessageBox.Show("Major: " & ver.Major & ", Minor: " & ver.Minor)
' ' check whether the current version is at least 2.7
' If ver.CompareTo(New Version(2, 7, 0, 0)) < 0 Then
' MessageBox.Show("MDAC version 2.7 or above is required!")
' End If
Function GetMdacVersion() As Version
' get the value of the FullInstallVer value under the HKLM\SOFTWARE\
' Microsoft\DataAccess key
Dim regKey As Microsoft.Win32.RegistryKey = _
Microsoft.Win32.Registry.LocalMachine.OpenSubKey( _
"SOFTWARE\Microsoft\DataAccess")
Dim ver As String = CType(regKey.GetValue("FullInstallVer", "0.0.0.0"), _
String)
regKey.Close()
' split the string in tokens and build a Version object
Dim verTokens() As String = ver.Split("."c)
Return New Version( Integer.Parse(verTokens(0)), Integer.Parse(verTokens(1)) _
, Integer.Parse(verTokens(2)), Integer.Parse(verTokens(3)))
End Function