It seems the function only stores STRING values? How can I store DWORD and BINARY values to the PPC registry?
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 ENDDUMP
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;
Return to FiveWin for Pocket PC
Users browsing this forum: No registered users and 12 guests