It seems the function only stores STRING values? How can I store DWORD and BINARY values to the PPC registry?
Thanks.
Bill Simmeth
Merchant Software Corp
Marshall, Virginia USA
Merchant Software Corp
Marshall, Virginia USA
It seems the function only stores STRING values? How can I store DWORD and BINARY values to the PPC registry?
Thanks.
Bill,
We are going to modify RegSetValue(), thanks
Very good, thanks!
HB_FUNC( REGSETVALUE )
{
LPWSTR pW1 = AnsiToWide( hb_parc( 2 ) );
switch( hb_itemType( hb_param( 3, HB_IT_ANY ) ) )
{
case HB_IT_STRING:
LPWSTR pW2 = AnsiToWide( hb_parc( 3 ) );
hb_retnl( RegSetValueEx( ( HKEY ) hb_parnl( 1 ), pW1, 0, REG_SZ, ( CONST BYTE * ) pW2,
( hb_parclen( 3 ) * 2 ) + 1 ) );
hb_xfree( pW2 );
break;
case HB_IT_INTEGER:
case HB_IT_LONG:
hb_retnl( RegSetValueEx( ( HKEY ) hb_parnl( 1 ), pW1, 0, REG_DWORD, ( const BYTE * ) hb_parnl( 3 ), sizeof( DWORD ) ) );
break;
}
hb_xfree( pW1 );
}//nHnd returned from RegOpenKey()
cVal := "AutoEnter"
nVal := 1
nResult := RegSetValue2( nHnd, cVal, nVal )#pragma BEGINDUMP
#include <hbapi.h>
#include <windows.h>
#include <item.api>
LPWSTR AnsiToWide( LPSTR );
HB_FUNC( REGSETVALUE2 )
{
LPWSTR pW1 = AnsiToWide( hb_parc( 2 ) );
LPWSTR pW2;
switch( hb_itemType( hb_param( 3, HB_IT_ANY ) ) )
{
case HB_IT_STRING:
pW2 = AnsiToWide( hb_parc( 3 ) );
hb_retnl( RegSetValueEx( ( HKEY ) hb_parnl( 1 ), pW1, 0, REG_SZ, ( CONST BYTE * ) pW2, ( hb_parclen( 3 ) * 2 ) + 1 ) );
break;
case HB_IT_INTEGER:
case HB_IT_LONG:
hb_retnl( RegSetValueEx( ( HKEY ) hb_parnl( 1 ), pW1, 0, REG_DWORD, ( const BYTE * ) hb_parnl( 3 ), sizeof( DWORD ) ) );
break;
}
hb_xfree( pW1 );
hb_xfree( pW2 );
}
#pragma ENDDUMPAntonio,
I would be in favor of adding an optional fourth parameter to allow for BINARY values. I have an important need for this.
Thanks,
Bill
Sorry, I forgot to add that using the function to set a REG_SZ (text) value works fine.
Bill,
We are going to review it asap
DWORD dwValue = hb_parnl( 3 );
...
case HB_IT_INTEGER:
case HB_IT_LONG:
hb_retnl( RegSetValueEx( ( HKEY ) hb_parnl( 1 ), pW1, 0, REG_DWORD, ( const BYTE * ) &dwValue, sizeof( DWORD ) ) );
break;Antonio, thanks. That change works. So, now REG_SZ and DWORD values are working.