2009-12-09 15:41 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)

* contrib/hbwin/win_regc.c
  * contrib/hbwin/win_prn3.c
  * contrib/hbwin/win_dll.c
    + Using new UNICODE parameter passing macros instead of HB_TCHAR*() ones.
    ; Please review me. The transition is not yet full, as there were 
      some problematic cases, which I've left as is.
    ! Added UNICODE support for WIN_REGQUERYVALUEEX()'s string return values.

  * contrib/hbwin/tests/testreg.prg
    + Added one more test call.
    ! Fixed to not use legacy registry call.
This commit is contained in:
Viktor Szakats
2009-12-09 14:45:54 +00:00
parent 094aea1ff3
commit 2551351908
5 changed files with 71 additions and 34 deletions

View File

@@ -17,6 +17,19 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-12-09 15:41 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbwin/win_regc.c
* contrib/hbwin/win_prn3.c
* contrib/hbwin/win_dll.c
+ Using new UNICODE parameter passing macros instead of HB_TCHAR*() ones.
; Please review me. The transition is not yet full, as there were
some problematic cases, which I've left as is.
! Added UNICODE support for WIN_REGQUERYVALUEEX()'s string return values.
* contrib/hbwin/tests/testreg.prg
+ Added one more test call.
! Fixed to not use legacy registry call.
2009-12-09 15:30 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbapilng.h
+ harbour/include/hbmsgreg.h

View File

@@ -11,9 +11,10 @@ PROCEDURE Main()
? ">" + wapi_GetCommandLine() + "<"
/* old API */
? ">" + hb_ValToStr( GetRegistry( HKEY_CURRENT_USER, "Control Panel\Desktop", "Wallpaper" ) ) + "<"
? ">" + hb_ValToStr( win_regGet( HKEY_CURRENT_USER, "Control Panel\Desktop", "Wallpaper" ) ) + "<"
/* new API */
? ">" + hb_ValToStr( win_regRead( "HKCU\Environment\PATH" ) ) + "<"
? ">" + hb_ValToStr( tmp := win_regRead( "HKCU\Control Panel\Desktop\Wallpaper" ) ) + "<"
? ">" + hb_ValToStr( win_regRead( "" ) ) + "<"

View File

@@ -64,6 +64,7 @@
#include "hbapi.h"
#include "hbapierr.h"
#include "hbapiitm.h"
#include "hbwinuni.h"
#if !defined( HB_NO_ASM ) && defined( HB_OS_WIN ) && !defined( __CYGWIN__ )
@@ -660,11 +661,11 @@ static LPVOID hb_getprocaddress( HMODULE hDLL, int iProc )
HB_FUNC( LOADLIBRARY )
{
LPTSTR lpName = HB_TCHAR_CONVTO( hb_parcx( 1 ) );
void * hName;
hb_retnint( ( HB_PTRDIFF ) LoadLibrary( lpName ) );
hb_retnint( ( HB_PTRDIFF ) LoadLibrary( ( LPCTSTR ) HB_PARSTRDEF( 1, &hName, NULL ) ) );
HB_TCHAR_FREE( lpName );
hb_strfree( hName );
}
HB_FUNC( FREELIBRARY )
@@ -711,11 +712,9 @@ HB_FUNC( DLLCALL )
hDLL = ( HMODULE ) ( HB_PTRDIFF ) hb_parnint( 1 );
else
{
LPTSTR lpName = HB_TCHAR_CONVTO( hb_parcx( 1 ) );
hDLL = LoadLibrary( lpName );
HB_TCHAR_FREE( lpName );
void * hName;
hDLL = LoadLibrary( ( LPCTSTR ) HB_PARSTRDEF( 1, &hName, NULL ) );
hb_strfree( hName );
}
if( hDLL && ( HB_PTRDIFF ) hDLL >= 32 )
@@ -739,9 +738,9 @@ HB_FUNC( DLLPREPARECALL )
if( HB_ISCHAR( 1 ) )
{
LPTSTR lpName = HB_TCHAR_CONVTO( hb_parc( 1 ) );
xec->hDLL = LoadLibrary( lpName );
HB_TCHAR_FREE( lpName );
void * hName;
xec->hDLL = LoadLibrary( ( LPCTSTR ) HB_PARSTRDEF( 1, &hName, NULL ) );
hb_strfree( hName );
}
else if( HB_ISPOINTER( 1 ) )
xec->hDLL = ( HMODULE ) hb_parptr( 1 );

View File

@@ -64,6 +64,7 @@
#define HB_OS_WIN_USED
#include "hbapi.h"
#include "hbwinuni.h"
static HB_BOOL hb_SetDefaultPrinter( LPTSTR lpPrinterName )
{
@@ -251,11 +252,11 @@ HB_FUNC( WIN_PRINTERSETDEFAULT )
{
if( hb_parclen( 1 ) > 0 )
{
LPTSTR lpPrinterName = HB_TCHAR_CONVTO( hb_parc( 1 ) );
void * hPrinterName;
hb_retl( hb_SetDefaultPrinter( lpPrinterName ) );
hb_retl( hb_SetDefaultPrinter( ( LPTSTR ) HB_PARSTR( 1, &hPrinterName, NULL ) ) );
HB_TCHAR_FREE( lpPrinterName );
hb_strfree( hPrinterName );
}
else
hb_retl( HB_FALSE );

View File

@@ -54,6 +54,7 @@
#include "hbapi.h"
#include "hbapiitm.h"
#include "hbwinuni.h"
static HKEY hb_regkeyconv( HB_PTRUINT nKey )
{
@@ -80,12 +81,12 @@ static HKEY hb_regkeyconv( HB_PTRUINT nKey )
HB_FUNC( WIN_REGCREATEKEYEX )
{
LPTSTR lpText = HB_TCHAR_CONVTO( hb_parcx( 2 ) );
void * hKey;
HKEY hkResult = NULL;
DWORD dwDisposition = 0;
hb_retl( RegCreateKeyEx( hb_regkeyconv( ( HB_PTRUINT ) hb_parnint( 1 ) ),
lpText,
( LPCTSTR ) HB_PARSTRDEF( 2, &hKey, NULL ),
0,
NULL,
hb_parnl( 5 ) /* dwOptions */,
@@ -97,23 +98,23 @@ HB_FUNC( WIN_REGCREATEKEYEX )
hb_storptr( hkResult, 8 );
hb_stornl( dwDisposition, 9 );
HB_TCHAR_FREE( lpText );
hb_strfree( hKey );
}
HB_FUNC( WIN_REGOPENKEYEX )
{
LPTSTR lpText = HB_TCHAR_CONVTO( hb_parcx( 2 ) );
void * hKey;
HKEY hkResult = NULL;
hb_retl( RegOpenKeyEx( hb_regkeyconv( ( HB_PTRUINT ) hb_parnint( 1 ) ),
lpText,
( LPCTSTR ) HB_PARSTRDEF( 2, &hKey, NULL ),
0 /* dwOptions */,
hb_parnl( 4 ) /* samDesired */,
&hkResult ) == ERROR_SUCCESS );
hb_storptr( hkResult, 5 );
HB_TCHAR_FREE( lpText );
hb_strfree( hKey );
}
HB_FUNC( WIN_REGQUERYVALUEEX )
@@ -131,17 +132,39 @@ HB_FUNC( WIN_REGQUERYVALUEEX )
{
if( dwSize > 0 )
{
BYTE * cValue = ( BYTE * ) hb_xgrab( dwSize + 1 );
if( dwType == REG_SZ || dwType == REG_EXPAND_SZ || dwType == REG_MULTI_SZ )
{
LPTSTR lpValue = ( LPTSTR ) hb_xgrab( ( dwSize + 1 ) * sizeof( TCHAR ) );
RegQueryValueEx( ( HKEY ) hb_parptr( 1 ),
lpKey,
NULL,
&dwType,
( BYTE * ) cValue,
&dwSize );
RegQueryValueEx( ( HKEY ) hb_parptr( 1 ),
lpKey,
NULL,
&dwType,
( LPBYTE ) lpValue,
&dwSize );
if( ! hb_storclen_buffer( ( char * ) cValue, dwSize, 5 ) )
hb_xfree( cValue );
#if defined( UNICODE )
dwSize >>= 1;
#endif
HB_STORSTRLEN( lpValue, dwSize, 5 );
hb_xfree( lpValue );
}
else /* No translation for binary data */
{
BYTE * cValue = ( BYTE * ) hb_xgrab( dwSize + 1 );
RegQueryValueEx( ( HKEY ) hb_parptr( 1 ),
lpKey,
NULL,
&dwType,
( LPBYTE ) cValue,
&dwSize );
if( ! hb_storclen_buffer( ( char * ) cValue, dwSize, 5 ) )
hb_xfree( cValue );
}
}
else
hb_storc( NULL, 5 );
@@ -157,14 +180,14 @@ HB_FUNC( WIN_REGQUERYVALUEEX )
HB_FUNC( WIN_REGSETVALUEEX )
{
LPTSTR lpKey = HB_TCHAR_CONVTO( hb_parcx( 2 ) );
void * hKey;
DWORD dwType = ( DWORD ) hb_parnl( 4 );
if( dwType == REG_DWORD )
{
DWORD nSpace = ( DWORD ) hb_parnl( 5 );
hb_retl( RegSetValueEx( ( HKEY ) hb_parptr( 1 ),
lpKey,
( LPCTSTR ) HB_PARSTRDEF( 2, &hKey, NULL ),
0,
dwType,
( BYTE * ) &nSpace,
@@ -172,13 +195,13 @@ HB_FUNC( WIN_REGSETVALUEEX )
}
else
hb_retl( RegSetValueEx( ( HKEY ) hb_parptr( 1 ),
lpKey,
( LPCTSTR ) HB_PARSTRDEF( 2, &hKey, NULL ),
0,
dwType,
( BYTE * ) hb_parcx( 5 ) /* cValue */,
hb_parclen( 5 ) + 1 ) == ERROR_SUCCESS );
HB_TCHAR_FREE( lpKey );
hb_strfree( hKey );
}
HB_FUNC( WIN_REGCLOSEKEY )