Page 1 of 1

RegEnumValue() return error 234

PostPosted: Wed Oct 09, 2019 9:31 am
by marzio
Hi at all.
i have inserted the sample regenum.prg in a my program compiled with borland 7.2 and all is ok (RegEnumValue() return 0)
if i compile the same program with visual c++ 2015 RegEnumValue() return 234 instead of 0 and doesn't work.
any idea?

thanks, marzio

Re: RegEnumValue() return error 234

PostPosted: Thu Oct 10, 2019 5:48 pm
by Antonio Linares

Re: RegEnumValue() return error 234

PostPosted: Thu Oct 10, 2019 5:50 pm
by Antonio Linares
https://docs.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regenumvaluea

Return Value
If the function succeeds, the return value is ERROR_SUCCESS.

If the function fails, the return value is a system error code. If there are no more values available, the function returns ERROR_NO_MORE_ITEMS.

If the lpData buffer is too small to receive the value, the function returns ERROR_MORE_DATA.

Re: RegEnumValue() return error 234

PostPosted: Fri Oct 11, 2019 9:01 am
by marzio
many thanks Antonio for your answer.
i have tried many options in the code below but i have had no success.
(i have tried many buffer dimensions till number of 32,767)
i obtain always the error code 234
please can you suggest me the right way so the code work fine?
marzio


Code: Select all  Expand view
#define  HKEY_LOCAL_MACHINE      2147483650
#define  ERROR_SUCCESS                    0

function Main()

   local hKey, cName, uValue := 2048, n := 0
   local lpData, lpcbData := 2048

   RegOpenKey( HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", @hKey )

   while RegEnumValue( hKey, n++, @cName, @uValue,,, @lpData, @lpcbData ) == ERROR_SUCCESS
      MsgInfo( cName )
      MsgInfo( uValue )
   end

   RegCloseKey( hKey )

return nil

Re: RegEnumValue() return error 234

PostPosted: Fri Oct 11, 2019 10:38 am
by Antonio Linares
The value that you are trying to retrieve is larger than 1024 bytes ?

Re: RegEnumValue() return error 234

PostPosted: Fri Oct 11, 2019 1:31 pm
by marzio
they are firewall informations like this long 150 to 170 characters obtained with compiling the example with bcc72:

v2.10|Action=Allow|Active=TRUE|Dir=In|Protocol=6|Profile=Domain|App=G:\winclip\applicazioni\contab\contab.exe|Name=contab|Desc=contab|Defer=User|

this is the key:

Code: Select all  Expand view
RegOpenKey( HKEY_LOCAL_MACHINE, "SYSTEM\CurrentControlSet\services\SharedAccess\Parameters\FirewallPolicy\FirewallRules", @nHandle )

anyway also the example from regenum.prg

Code: Select all  Expand view
RegOpenKey( HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", @hKey )

compiled with visual c++ returns error 234 !!

your example file regenum.prg works fine with visual c++ 32 and 64 bit?
.

Re: RegEnumValue() return error 234

PostPosted: Sun Oct 13, 2019 8:33 am
by Antonio Linares
regenum.prg is working fine using MSVC 64 but it shows nothing

Code: Select all  Expand view
// Retrieving all values from a registry entry

#include "FiveWin.ch"

#define  HKEY_LOCAL_MACHINE      2147483650

#define  ERROR_SUCCESS                    0

//---------------------------------------------------------------------------//

function Main()

   local hKey, cName, uValue, n := 0

   RegOpenKey( HKEY_LOCAL_MACHINE,;
               "Software\Microsoft\Windows\CurrentVersion\Run", @hKey )
   
   while RegEnumValue( hKey, n++, @cName, @uValue ) == ERROR_SUCCESS
      MsgInfo( cName )
      MsgInfo( uValue )
   end

   MsgInfo( "ok" )

   RegCloseKey( hKey )

return nil

//---------------------------------------------------------------------------//

Re: RegEnumValue() return error 234

PostPosted: Mon Oct 14, 2019 7:12 am
by marzio
Antonio you say: "regenum.prg is working fine using MSVC 64 but it shows nothing"

Why regenum with MSVC shows nothing, while with BCC72 shows 8 keys and 8 values presents in my windows register?

Try to put:

Code: Select all  Expand view
RegOpenKey( HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\CurrentVersion\Run", @hKey )
? RegEnumValue( hKey, n, @cName, @uValue )

in regenum.prg to see if return 0 or 234 compiled with MSVC
.