1. Olan Knight
  2. PowerBuilder
  3. Monday, 29 October 2018 22:06 PM UTC

Update:
   Much research revealed this thread from July 19, 2016 at 18:31 PM:
                     https://archive.sap.com/discussions/thread/3930331


Still trying to use the example and learn how to retrieve and read STRING data.


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

PB v12.5.1, b7055
Wundows 7, 64-bit platform


ls_hklm = "HKEY_LOCAL_MACHINE\SOFTWARE\"
ll_rc   = RegistryGet (ls_hklm, "Wow6432Node", RegString!, ls_data)
// ll_rc = -1


ls_hklm = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node"
ll_rc   = RegistryGet (ls_hklm, "", RegString!, ls_data)
// ll_rc = -1


What gives? This is blatantly incorrect.

Olan Knight Accepted Answer Pending Moderation
  1. Tuesday, 30 October 2018 14:39 PM UTC
  2. PowerBuilder
  3. # 1

Roland -

   Thanks for the response! I tried it both ways, including this way and still got a -1 result code.

ls_hklm = "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node"
ll_rc   = RegistryGet (ls_hklm, "", RegString!, ls_data)
// ll_rc = -1

According to the documentation that second parameter can be an empty string.
valuename    A string containing the name of a value in the registry. Each key can have one unnamed value and several named values. For the unnamed value, specify an empty string.

After reading the SAP thread I've been trying to use the Microsoft Functions.



Tom -
    Thanks for the response! Can you post examples of how to use the MS APIs?


Here's what I have from the SAP thread.

// External Function declarations
FUNCTION uLong RegOpenKeyEx(uLong hKey, Ref String lpSubKey, uLong ulOptions, &
                                     uLong samDesired, Ref uLong phkResult)                          &
    LIBRARY "advapi32.dll" ALIAS FOR "RegOpenKeyExW"

FUNCTION uLong RegCloseKey(uLong hKey)     &
    LIBRARY "advapi32.dll"

FUNCTION uLong RegQueryValueEx (uLong hKey, String lpValueName, uLong lpReserved,  &
                                            ref uLong lpType, ref Long lpData, ref uLong lpcbData)      &
    LIBRARY "advapi32.dll" ALIAS FOR "RegQueryValueExW"


// in a function - all of this is from the SAP thread and I'll test it today
CONSTANT ulong ERROR_NONE                  = 0
CONSTANT ulong KEY_QUERY_VALUE         = 1                        // 1 = READ access
CONSTANT ulong KEY_ALL_ACCESS            = 983087               // ALL access: read, create, delete
//CONSTANT ulong KEY_ALL_ACCESS         = 63
CONSTANT ulong KEY_SET_VALUE             = 2               // Required to create, delete, or set a registry value.
CONSTANT ulong KEY_WOW64_64KEY       = 256                    // Use the 64-bit registry view
CONSTANT ulong HKEY_CURRENT_USER     = 2147483649
CONSTANT ulong HKEY_LOCAL_MACHINE    = 2147483650

Long       ll_Handle, ll_rc
String     ls_Key     = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows"
String     ls_Value  = "USERProcessHandleQuota"
String     ls_return, ls_data
uLong    lul_Key, lul_Result, lul_Type, lul_Data = 4           // Types:  REG_SZ, REG_DWORD, REG_BINARY


// Example from the thread:
ll_rc = RegOpenKeyEx( HKEY_LOCAL_MACHINE, ls_Key, 0, KEY_QUERY_VALUE + KEY_WOW64_64KEY, lul_Key)
IF ll_rc = ERROR_NONE THEN

  lul_Result = RegQueryValueEx ( lul_Key, ls_Value, 0, lul_Type, ll_Handle, lul_Data)

  RegCloseKey (lul_Key)

END IF

// If I understand what is happening above,
RegOpenKeyEx - parameter #1 identifies the top layer in the registry to access
                        parameter #2 is the path to the folder of the subkey to be accessed
                        parameter #3 is reserved - do not touch
                        parameter #4 identifies if we are accessing a 32 or 64 bit version of the Registry,
                                            and the action we are taking on the subkey entry
                        parameter #5 will be the pointer to the data to be read

RegQueryValueEx - parameter #1 is the pointer to the data to be read
                           parameter #2 indicates which subkey is to be read
                           parameter #3 is reserved - do not touch
                           parameter #4 a pointer to the datatype of the subkey
                           parameter #5 will be the pointer to the subkey data
                           parameter #6 is the lenfgth of the pointer of parm #5


Based on the above, the "lul_type" value is zero by default, so I assumethat zero indicates NUMERIC data is to be retrieved.

What I need is STRING data, but nowhere can I find the value of the parameter "lul_type" for string data.

Oh, it would be nice to have the values for the other datatypes as well!  :)

UPDATE:  Found that information:    https://www.motobit.com/help/RegEdit/cl72.htm

 

Thanks,

Olan

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Tuesday, 30 October 2018 01:48 AM UTC
  2. PowerBuilder
  3. # 2

The first argument is the folder path and the second argument is the name of a value under the given folder. In your examples the second argument appears to be a folder name.

Comment
There are no comments made yet.
Tom Jiang @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 30 October 2018 01:10 AM UTC
  2. PowerBuilder
  3. # 3

Hi Olan,

It's probably because you are trying to get an unname value but the value is not set. 

Regards,

Tom Jiang

Comment
There are no comments made yet.
Olan Knight Accepted Answer Pending Moderation
  1. Monday, 29 October 2018 23:10 PM UTC
  2. PowerBuilder
  3. # 4

Update - incorporated into the question.

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.