2009-12-11 20:16 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)

* contrib/hbwin/wapi_winbase.c
    * Eliminated hb_parclen() call in WAPI_FORMATMESSAGE() function.

  * contrib/hbwin/win_regc.c
    * WIN_REGSETVALUEEX(): Adjusted casting to not drop const.
    ! WIN_REGSETVALUEEX(): Added support for UNICODE builds when 
      string types (non-binary data) are passed.

  * contrib/hbwin/tests/testreg.prg
    + Extended with basic test for above.
This commit is contained in:
Viktor Szakats
2009-12-11 19:21:56 +00:00
parent 81effeca0c
commit aa13701479
4 changed files with 47 additions and 6 deletions

View File

@@ -17,6 +17,18 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-12-11 20:16 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbwin/wapi_winbase.c
* Eliminated hb_parclen() call in WAPI_FORMATMESSAGE() function.
* contrib/hbwin/win_regc.c
* WIN_REGSETVALUEEX(): Adjusted casting to not drop const.
! WIN_REGSETVALUEEX(): Added support for UNICODE builds when
string types (non-binary data) are passed.
* contrib/hbwin/tests/testreg.prg
+ Extended with basic test for above.
2009-12-11 19:56 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbwin/wce_smsc.c
+ Eliminated hb_parclen() usage.

View File

@@ -19,6 +19,7 @@ PROCEDURE Main()
? ">" + hb_ValToStr( win_regRead( "" ) ) + "<"
? win_regWrite( "HKCU\Control Panel\Desktop\Wallpaper", "harbour.bmp" )
? win_regRead( "HKCU\Control Panel\Desktop\Wallpaper" )
Inkey( 0 )

View File

@@ -215,17 +215,23 @@ HB_FUNC( WAPI_OUTPUTDEBUGSTRING )
HB_FUNC( WAPI_FORMATMESSAGE )
{
void * hSource = NULL;
void * hBuffer;
DWORD dwBufferLen = ( DWORD ) hb_parclen( 5 );
LPTSTR lpBuffer = dwBufferLen > 0 ? ( LPTSTR ) hb_xgrab( dwBufferLen * sizeof( TCHAR ) ) : NULL;
HB_SIZE nBufferLen;
LPTSTR lpBuffer;
DWORD dwRetVal;
( void ) HB_PARSTR( 5, &hBuffer, &nBufferLen );
lpBuffer = nBufferLen > 0 ? ( LPTSTR ) hb_xgrab( nBufferLen * sizeof( TCHAR ) ) : NULL;
hb_retnl( dwRetVal = FormatMessage( ( DWORD ) hb_parnldef( 1, FORMAT_MESSAGE_FROM_SYSTEM ) /* dwFlags */,
HB_ISCHAR( 2 ) ? ( LPCVOID ) HB_PARSTR( 2, &hSource, NULL ) : hb_parptr( 2 ),
HB_ISNUM( 3 ) ? ( DWORD ) hb_parnl( 3 ) : GetLastError() /* dwMessageId */,
( DWORD ) hb_parnldef( 4, MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ) ) /* dwLanguageId */,
lpBuffer,
dwBufferLen,
( DWORD ) nBufferLen,
NULL /* TODO: Add support for this parameter. */ ) );
if( lpBuffer )
@@ -237,4 +243,5 @@ HB_FUNC( WAPI_FORMATMESSAGE )
hb_storc( NULL, 5 );
hb_strfree( hSource );
hb_strfree( hBuffer );
}

View File

@@ -193,15 +193,36 @@ HB_FUNC( WIN_REGSETVALUEEX )
HB_PARSTRDEF( 2, &hKey, NULL ),
0,
dwType,
( BYTE * ) &nSpace,
( const BYTE * ) &nSpace,
sizeof( REG_DWORD ) ) == ERROR_SUCCESS );
}
else
else if( dwType == REG_SZ ||
dwType == REG_EXPAND_SZ ||
dwType == REG_MULTI_SZ )
{
void * hValue;
HB_SIZE nValueLen;
LPCTSTR lpValue = HB_PARSTR( 5, &hValue, &nValueLen );
#if defined( UNICODE )
nValueLen *= 2;
#endif
hb_retl( RegSetValueEx( ( HKEY ) hb_parptr( 1 ),
HB_PARSTRDEF( 2, &hKey, NULL ),
0,
dwType,
( BYTE * ) hb_parcx( 5 ) /* cValue */,
( const BYTE * ) lpValue,
( DWORD ) nValueLen + 1 ) == ERROR_SUCCESS );
hb_strfree( hValue );
}
else /* No translation for binary data */
hb_retl( RegSetValueEx( ( HKEY ) hb_parptr( 1 ),
HB_PARSTRDEF( 2, &hKey, NULL ),
0,
dwType,
( const BYTE * ) hb_parc( 5 ) /* cValue */,
hb_parclen( 5 ) + 1 ) == ERROR_SUCCESS );
hb_strfree( hKey );