Unanswered: Problem retrieving registry value after going from Access 97 to Access 2002
I have a problem in an MS access application going from Access 97 to Access 2002, i.e. it works okay under Access 97 and it fails under 2002.
I'm running Windows XP SP3 and not as a local admin.
The MS access application is used to make a connection with an emulator session on an AS/400 (PC5250 - iSeries Access). In order to get the correct installation path of this emulator session it reads a registry entry and that's were it goes wrong.
' Declare api specific variables
Private apiReturnCode As Long
Private apiCallStatus As Long
Private apiLength As Long
Private apiReturnData As String * 8000
Private Const apicCurrentUser = &H80000001
Private Const apicLocalMachine = &H80000002
Private Const apicEmulator = "SOFTWARE\IBM\Client Access\CurrentVersion\Selectively_Installable_Components\Emulator"
Private Const apicPath = "InstallPath"
Private Const apicMaxSize = 150
Private Const apicRegNoError = 0
Private Const apicErrRegKeyNotFound = -201
Private Const apicErrRegValueNotFound = -202
Private Const apicErrRegCantSetValue = -203
Private Const apicErrRegSubKeyNotFound = -204
Private Const apicErrRegTypeNotSupported = -205
Private Const apicErrRegCantCreateKey = -206
Declare Function GetRegistryValue Lib "msaccess.exe" Alias "#70" (ByVal hkeyRoot As Long, _
ByVal strSubKey As String, ByVal strValName As String, _
lpData As Any, ByVal lngMaxLen As Long) As Long
Public Sub apiConnect(strSession As String)
On Error GoTo apiConnectError
Dim intNullFound As Integer
Dim strEmulatorPath As String
Dim lngReturnValue As Long
Dim strReturnValue As String
apiReturnCode = gconNoError
apiReturnData = strSession
strEmulatorPath = Space(apicMaxSize)
' Prior to making a connection attempt the current drive and path must be set to that of the
' IBM iSeries Access Emulator to allow for the PCSHLL32.DLL to work. The actual path will be
' retrieved from the appropriate registry entries.
lngReturnValue = GetRegistryValue(apicLocalMachine, apicEmulator, apicPath, _
ByVal strEmulatorPath, apicMaxSize)
If lngReturnValue <> apicRegNoError Then
Call AuditLog("Unable to find registry entry: " & lngReturnValue, 99, gconAuditError, gintPage)
Err.Raise Number:=20004, Description:="iSeries Access Installation Path missing"
When using this code under Access 97 it works fine. When trying to run this under Access 2002 the GetRegistryValue function returns with a value -201, which means "registry key not found".
The result is the same with the database in 97-format and in 2002-format.
I have tried to replace the function GetRegistryValue with the function fReturnRegKeyValue which I found in http://www.mvps.org/access/api/api0015.htm, but the result stayed the same "Error: Key or Value Not Found.".
Since the registry-key is there (Access 97 is able to find it correctly) there must be something else going on.