Can access read values from the registry?

  • Thread starter Thread starter Brandon M
  • Start date Start date
Brandon M said:
Is it possible to get access to read a value from the windows 98 registry?
Hi Brandon,

I have used MVP module with success.

http://www.mvps.org/access/api/api0015.htm

Just save it in a module, then use function

fReturnRegKeyValue(...)

in your code.


for example (no error checking):

Private Function GetComputerInfo()
Dim os As String, AccVer As String, AccInstallPath As String
Dim WinVer As String, DAOPath As String

'Computer Name
Me!txtComputerName = fReturnRegKeyValue(HKEY_LOCAL_MACHINE, _
"System\CurrentControlSet\Control\ComputerName\ComputerName", _
"ComputerName")

'Operating System
os = fReturnRegKeyValue(HKEY_LOCAL_MACHINE, _
"SOFTWARE\Microsoft\Windows\CurrentVersion", "ProductName")
If os <> "Error: Key or Value Not Found." Then
Me!txtOS = os
Else
os = fReturnRegKeyValue(HKEY_LOCAL_MACHINE, _
"SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ProductName")
If os <> "Error: Key or Value Not Found." Then
Me!txtOS = os
Else
os = "Could not determine"
End If
End If

'Access
AccInstallPath = fReturnRegKeyValue(HKEY_LOCAL_MACHINE, _
"SOFTWARE\Microsoft\Office\9.0\Access\InstallRoot", "Path")
If AccInstallPath <> "Error: Key or Value Not Found." Then
'"9.0"
Me!txtAccessInstallPath = AccInstallPath
Else
AccInstallPath = fReturnRegKeyValue(HKEY_LOCAL_MACHINE, _
"SOFTWARE\Microsoft\Office\10.0\Access\InstallRoot", "Path")
If AccInstallPath <> "Error: Key or Value Not Found." Then
'"10.0"
Me!txtAccessInstallPath = AccInstallPath
Else
AccInstallPath = fReturnRegKeyValue(HKEY_LOCAL_MACHINE, _
"SOFTWARE\Microsoft\Office\8.0\Access\InstallRoot", "Path")
If AccInstallPath <> "Error: Key or Value Not Found." Then
'"8.0"
Me!txtAccessInstallPath = AccInstallPath

End If
End If
End If
If FileExists(AccInstallPath & "msaccess.exe") Then
Me!txtAccVersion = GetFileVersion(AccInstallPath & "msaccess.exe")
End If

'DAO
DAOPath = fReturnRegKeyValue(HKEY_LOCAL_MACHINE, _
"SOFTWARE\Microsoft\Shared Tools", "SharedFilesDir")
If DAOPath <> "Error: Key or Value Not Found." Then
If FileExists(DAOPath & "DAO\dao360.dll") Then
Me!txtDAOPath = DAOPath
Else
Me!txtDAOPath = "Could not determine"
End If
Else
Me!txtDAOPath = "Could not determine"
End If


End Function

It's been awhile and looking at code...I'm going to have to
update this for the new versions of Access!!

Good luck,

Gary Walter
 
Back
Top