function REGQUERYVALUE() not ready

function REGQUERYVALUE() not ready

Postby HATHAL » Tue Dec 26, 2006 3: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 .
User avatar
HATHAL
 
Posts: 77
Joined: Tue Nov 15, 2005 3:38 pm
Location: The Kingdom Saudi Arabia -Riyadh

Postby Antonio Linares » Thu Dec 28, 2006 8:09 am

Hathal,

You have to do it this way:
Code: Select all  Expand view  RUN
#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:
Code: Select all  Expand view  RUN
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42120
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby HATHAL » Thu Dec 28, 2006 8:24 pm

Antonio.
I have many item in Registrar "run".
He Is Return one Only.
I have 9 item .
he is return item 8
:?:
User avatar
HATHAL
 
Posts: 77
Joined: Tue Nov 15, 2005 3:38 pm
Location: The Kingdom Saudi Arabia -Riyadh

Postby Antonio Linares » Fri Dec 29, 2006 7:01 am

Hathal,

Here it is working fine. Please review your code implementation.
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42120
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby HATHAL » Sun Dec 31, 2006 7: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
// -----------------------------------------------
User avatar
HATHAL
 
Posts: 77
Joined: Tue Nov 15, 2005 3:38 pm
Location: The Kingdom Saudi Arabia -Riyadh


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 63 guests