Symptom

Moved development from Windows XP to Windows 7 and now the RegistryGet() function is not working.  It returns a -1.

Environment

PowerBuilder

Windows 7

Reproducing the Issue

The following code behind a button control returns -1:

longll_ret

stringls_keyvalue

ll_ret = RegistryGet("HKEY_LOCAL_MACHINE\Software\MYAPP", "Version", RegString!, ls_keyvalue)
MessageBox("Registry", string(ll_ret) + " " + ls_keyvalue)

Cause

This problem is due to 64-bit vs. 32-bit access.  PowerBuilder is a 32-bit application so the registry key needs to be in the 32-bit area (wow6432node) of the registry.

Resolution

Moving the registry key to the Wow6432Node solves the problem:

One way to move the registry key is by exporting the original key, editing the file to show the new location and installing the key.  To accomplish that do the following:

1.  Run regedit.exe and locate the key HKEY_LOCAL_MACHINE\Software\MyApp.

2.  Right click on the registry key and select Export and name the file MyApp.reg.

3.  Locate MyAppreg and edit it as follows:

     From:

        Windows Registry Editor Version 5.00

        [HKEY_LOCAL_MACHINE\SOFTWARE\MyApp]
        "Version"="1.0"

     To:

        Windows Registry Editor Version 5.00

        [HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\MyApp]
        "Version"="1.0"

4.  Save the file.

5.  Doubleclick on the MyApp.reg file to install it to the registry.

The following code behind the button now returns the registry key value:

longll_ret

stringls_keyvalue

ll_ret = RegistryGet("HKEY_LOCAL_MACHINE\Software\Wow6432Node\MyApp", "Version", RegString!, ls_keyvalue)
MessageBox("Registry", string(ll_ret) + " " + ls_keyvalue)

1
1