FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour function REGQUERYVALUE() not ready
Posts: 80
Joined: Tue Nov 15, 2005 03:38 PM
function REGQUERYVALUE() not ready
Posted: Tue Dec 26, 2006 03:57 PM

urgent for Antonio.
appeal to the problem in Returning the information from the Registrar

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run.
I want the information in the Registrar Run.
function REGQUERYVALUE() not ready
hathal .

:?:

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
function REGQUERYVALUE() not ready
Posted: Thu Dec 28, 2006 08:09 AM
Hathal,

You have to do it this way:
#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

   RegCloseKey( hKey )

return nil

And add this function to source\winapi\regedit.c:
#ifdef __HARBOUR__
   CLIPPER REGENUMVALUE( PARAMS ) // ( nKey, nIndex, @cKeyName, @uValue ) --> nResult
#else
   CLIPPER REGENUMVAL( PARAMS ) // UE( nKey, nIndex, @cKeyName, @uValue ) --> nResult
#endif
{
   BYTE name[ 256 ];
   BYTE value[ 256 ];
   LONG lName, lValue;
   DWORD type;

   _retnl( RegEnumValue( ( HKEY ) _parnl( 1 ), _parnl( 2 ), ( char * ) name, &lName,
                         NULL, &type, ( char * ) value, &lValue ) );
   _storc( ( char * ) name, 3 );                      
   
   switch( type )
   {
      case REG_SZ:
      	   _storc( ( char * ) value, 4 );
      	   break;
      	   
      case REG_DWORD:
      	   _stornl( * ( ( LPDWORD ) value ), 4 );
      	   break;	   
   }   		
}

Please notice that the above function is not complete yet, though it works fine for the above sample
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 80
Joined: Tue Nov 15, 2005 03:38 PM
function REGQUERYVALUE() not ready
Posted: Thu Dec 28, 2006 08:24 PM

Antonio.
I have many item in Registrar "run".
He Is Return one Only.
I have 9 item .
he is return item 8

:?:

Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
function REGQUERYVALUE() not ready
Posted: Fri Dec 29, 2006 07:01 AM

Hathal,

Here it is working fine. Please review your code implementation.

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 80
Joined: Tue Nov 15, 2005 03:38 PM
function REGQUERYVALUE() not ready
Posted: Sun Dec 31, 2006 07:58 AM

Thank Antonio for help me.
I am working on Borland c source did not work with me in the required way.
But adjusted and became 100% see the source after the amendment.
Thank you.
hathal.

// --------- source --------------------------------------

include "FiveWin.ch"

include "Struct.ch"

define HKEY_LOCAL_MACHINE 2147483650

define ERROR_SUCCESS 0

define HKEY_CURRENT_USER 2147483649 // 0x80000001

function Main()
local hKey, cName:="", uValue:="", na_reg := 0
RegOpenKey( HKEY_LOCAL_MACHINE,;
"Software\Microsoft\Windows\CurrentVersion\Run", @hKey )
while RegEnumValue( hKey,na_reg++, @cName, @uValue ) == ERROR_SUCCESS
MsgInfo( cName,na_reg )
MsgInfo( uValue )
/ end
RegCloseKey( hKey )
return nil


pragma BEGINDUMP

include <windows.h>

include "hbapiitm.h"

include "hbvm.h"

include "hbstack.h"

include "item.api"

include "hbpcode.h"

include "hbvmpub.h"

HB_FUNC ( REGENUMVALUE ) // ( nKey, nIndex, @cKeyName, @uValue ) --> nResult
{
BYTE value[1024 ];
TCHAR szName[1024];
DWORD dwDataSize, dwSizeName;
DWORD dwSize,dwType,dwDisp;
LPBYTE lpData = 0;
char ret_value[1024];
int ret;
hb_retnl(RegEnumValue(( HKEY ) hb_parnl( 1 ), hb_parnl( 2 ), szName, &dwSizeName, NULL, &dwType,lpData, &dwDataSize));
RegQueryValueEx(( HKEY ) hb_parnl( 1 ),szName , NULL, &dwType, (unsigned char)&ret_value, &dwSize);
hb_storc( ( char * ) szName, 3 );
// MessageBox(NULL,ret_value,"ret_value",MB_ICONQUESTION|MB_SYSTEMMODAL|MB_APPLMODAL|MB_TASKMODAL|MB_SETFOREGROUND|MB_TOPMOST|MB_YESNO);
switch( dwType )
{
case REG_SZ:
strcpy(value,ret_value);
hb_storc( ( char * ) value, 4 );
break;
case REG_DWORD:
ret =
(( LPDWORD ) ret_value);
hb_stornl( ( int ) ret , 4 );
break;
/*
REG_MULTI_SZ:
REG_EXPAND_SZ:
REG_BINARY:
REG_FULL_RESOURCE_DESCRIPTOR:

*/
}

}

pragma ENDDUMP

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

Continue the discussion