|
|
Title | Determine what version of Access is installed by reading Registry values in Visual Basic 2005 |
Description | This example shows how to determine what version of Access is installed by reading Registry values in Visual Basic 2005. |
Keywords | Access, Access version, Microsoft Access, Registry, VB.NET, Visual Basic 2005 |
Categories | Office, Software Engineering, Tips and Tricks, VB.NET |
|
|
Function GetAccessVersionName looks at the Registry key HKEY_CLASSES_ROOT\Access.Application\CurVer to get the current Access version. The other routines use the result returned by this one to get Access's number and "nice" name.
|
|
' Determine the Access version by looking at
' HKEY_CLASSES_ROOT\Access.Application\CurVer.
Public Function GetAccessVersionName() As String
Dim key As RegistryKey = _
Registry.ClassesRoot.OpenSubKey( _
"Access.Application\\CurVer")
Dim result As String = key.GetValue("")
key.Close()
Return result
End Function
' Get the Access version number from the name.
Public Function GetAccessVersionNumber() As Integer
Dim txt As String = GetAccessVersionName()
Return txt.Substring(txt.LastIndexOf(".") + 1)
End Function
' Get the nice style of the Access version name.
Public Function GetAccessVersionNiceName() As String
Select Case GetAccessVersionNumber()
Case 8
Return "Access 97"
Case 9
Return "Access 2000"
Case 10
Return "Access 2002" ' XP
Case 11
Return "Access 2003"
Case 12
Return "Access 2007"
Case Else
Return "unknown"
End Select
End Function
|
|
|
|
|
|