2011-04-26 16:28 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)

* contrib/hbwin/hbwin.ch
  * contrib/hbwin/win_regc.c
  * contrib/hbwin/win_reg.prg
  * contrib/hbwin/tests/testreg.prg
    + added type parameter to win_regWrite()/win_regSet()/win_regSetValueEx() functions
    + added QWORD support in win registry
    ! fixed very old xhb typo: sizeof( REG_DWORD ) -> sizeof( DWORD )
      (didn't cause actual error in compiled code)
    + added REG_DWORD, REG_QWORD tests

  * package/mpkg_win.nsi
  * package/winuni/mpkg_win_uni.nsi
    * uninstall icon changed to better looking one
This commit is contained in:
Viktor Szakats
2011-04-26 14:29:38 +00:00
parent 00da0a4518
commit dc2edce1ef
7 changed files with 80 additions and 24 deletions

View File

@@ -16,6 +16,21 @@
The license applies to all entries newer than 2009-04-28.
*/
2011-04-26 16:28 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbwin/hbwin.ch
* contrib/hbwin/win_regc.c
* contrib/hbwin/win_reg.prg
* contrib/hbwin/tests/testreg.prg
+ added type parameter to win_regWrite()/win_regSet()/win_regSetValueEx() functions
+ added QWORD support in win registry
! fixed very old xhb typo: sizeof( REG_DWORD ) -> sizeof( DWORD )
(didn't cause actual error in compiled code)
+ added REG_DWORD, REG_QWORD tests
* package/mpkg_win.nsi
* package/winuni/mpkg_win_uni.nsi
* uninstall icon changed to better looking one
2011-04-26 14:34 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* package/harb_osx.icns
* package/harb_win.ico

View File

@@ -70,6 +70,22 @@
#define WIN_HKEY_CURRENT_CONFIG 0x80000005
#define WIN_HKEY_DYN_DATA 0x80000006
/* Windows registry key types in win_regWrite()/win_regSet()/win_regSetValueEx() functions */
#define WIN_REG_NONE 0 /* No value type */
#define WIN_REG_SZ 1 /* Unicode nul terminated string */
#define WIN_REG_EXPAND_SZ 2 /* Unicode nul terminated string (with environment variable references) */
#define WIN_REG_BINARY 3 /* Free form binary */
#define WIN_REG_DWORD 4 /* 32-bit number */
#define WIN_REG_DWORD_LITTLE_ENDIAN 4 /* 32-bit number (same as REG_DWORD) */
#define WIN_REG_DWORD_BIG_ENDIAN 5 /* 32-bit number */
#define WIN_REG_LINK 6 /* Symbolic Link (unicode) */
#define WIN_REG_MULTI_SZ 7 /* Multiple Unicode strings */
#define WIN_REG_RESOURCE_LIST 8 /* Resource list in the resource map */
#define WIN_REG_FULL_RESOURCE_DESCRIPTOR 9 /* Resource list in the hardware description */
#define WIN_REG_RESOURCE_REQUIREMENTS_LIST 10
#define WIN_REG_QWORD 11 /* 64-bit number */
#define WIN_REG_QWORD_LITTLE_ENDIAN 11 /* 64-bit number (same as REG_QWORD) */
/* WIN_PORT() related values */
/* WIN_COMOPEN() bit rates */

View File

@@ -7,6 +7,14 @@
PROCEDURE Main()
LOCAL tmp
? win_regWrite( "HKCU\_TEST\mydword", 0x11223344, WIN_REG_DWORD )
? hb_numtohex( win_regRead( "HKCU\_TEST\mydword" ) )
? win_regWrite( "HKCU\_TEST\myqword", 0x1122334455667788, WIN_REG_QWORD )
? hb_numtohex( win_regRead( "HKCU\_TEST\myqword" ) )
Inkey( 0 )
? win_regDelete( "HKCU\_TEST\teszt" )
? win_regDelete( "HKCU\_TEST\" )

View File

@@ -64,19 +64,6 @@
#define KEY_NOTIFY 16
#define KEY_CREATE_LINK 32
#define REG_NONE 0 // No value type
#define REG_SZ 1 // Unicode nul terminated string
#define REG_EXPAND_SZ 2 // Unicode nul terminated string (with environment variable references)
#define REG_BINARY 3 // Free form binary
#define REG_DWORD 4 // 32-bit number
#define REG_DWORD_LITTLE_ENDIAN 4 // 32-bit number (same as REG_DWORD)
#define REG_DWORD_BIG_ENDIAN 5 // 32-bit number
#define REG_LINK 6 // Symbolic Link (unicode)
#define REG_MULTI_SZ 7 // Multiple Unicode strings
#define REG_RESOURCE_LIST 8 // Resource list in the resource map
#define REG_FULL_RESOURCE_DESCRIPTOR 9 // Resource list in the hardware description
#define REG_RESOURCE_REQUIREMENTS_LIST 10
/* ------------------------------------------------------------------- */
PROCEDURE win_regPathSplit( cRegPath, /* @ */ nHKEY, /* @ */ cKey, /* @ */ cEntry )
@@ -128,12 +115,12 @@ FUNCTION win_regRead( cRegPath, xDefault )
RETURN win_regGet( nHKEY, cKey, cEntry, xDefault )
FUNCTION win_regWrite( cRegPath, xValue )
FUNCTION win_regWrite( cRegPath, xValue, nType )
LOCAL nHKEY, cKey, cEntry
win_regPathSplit( cRegPath, @nHKEY, @cKey, @cEntry )
RETURN win_regSet( nHKEY, cKey, cEntry, xValue )
RETURN win_regSet( nHKEY, cKey, cEntry, xValue, nType )
FUNCTION win_regDelete( cRegPath )
LOCAL nHKEY, cKey, cEntry
@@ -197,10 +184,15 @@ FUNCTION win_regGet( nHKEY, cKeyName, cEntryName, xDefault )
IF ISCHARACTER( xRetVal )
DO CASE
CASE nValueType == REG_DWORD .OR. nValueType == REG_DWORD_LITTLE_ENDIAN
CASE nValueType == WIN_REG_DWORD .OR. ;
nValueType == WIN_REG_DWORD_LITTLE_ENDIAN
xRetVal := Bin2U( xRetVal )
CASE nValueType == REG_DWORD_BIG_ENDIAN
CASE nValueType == WIN_REG_DWORD_BIG_ENDIAN
xRetVal := Bin2U( Right( xRetVal, 2 ) + Left( xRetVal, 2 ) )
CASE nValueType == WIN_REG_QWORD .OR. ;
nValueType == WIN_REG_QWORD_LITTLE_ENDIAN
xRetVal := hb_bitShift( Bin2U( SubStr( xRetVal, 5, 2 ) + SubStr( xRetVal, 7, 2 ) ), 32 ) +;
Bin2U( SubStr( xRetVal, 1, 2 ) + SubStr( xRetVal, 3, 2 ) )
OTHERWISE
/* Strip ending zero byte */
IF Right( xRetVal, 1 ) == Chr( 0 )
@@ -218,9 +210,8 @@ FUNCTION win_regGet( nHKEY, cKeyName, cEntryName, xDefault )
RETURN xRetVal
FUNCTION win_regSet( nHKEY, cKeyName, cEntryName, xValue )
FUNCTION win_regSet( nHKEY, cKeyName, cEntryName, xValue, nValueType )
LOCAL cName
LOCAL nValueType
LOCAL lRetVal := .F.
LOCAL pKeyHandle
@@ -229,20 +220,32 @@ FUNCTION win_regSet( nHKEY, cKeyName, cEntryName, xValue )
/* no support for Arrays, Codeblock ... */
SWITCH ValType( xValue )
CASE "L"
nValueType := REG_DWORD
nValueType := WIN_REG_DWORD
cName := iif( xValue, 1, 0 )
EXIT
CASE "D"
nValueType := REG_SZ
nValueType := WIN_REG_SZ
cName := DToS( xValue )
EXIT
CASE "N"
nValueType := REG_DWORD
IF ! hb_isNumeric( nValueType ) .OR. ;
!( nValueType == WIN_REG_DWORD .OR. ;
nValueType == WIN_REG_DWORD_LITTLE_ENDIAN .OR. ;
nValueType == WIN_REG_DWORD_BIG_ENDIAN .OR. ;
nValueType == WIN_REG_QWORD .OR. ;
nValueType == WIN_REG_QWORD_LITTLE_ENDIAN )
nValueType := WIN_REG_DWORD
ENDIF
cName := xValue
EXIT
CASE "C"
CASE "M"
nValueType := REG_SZ
IF ! hb_isNumeric( nValueType ) .OR. ;
!( nValueType == WIN_REG_SZ .OR. ;
nValueType == WIN_REG_EXPAND_SZ .OR. ;
nValueType == WIN_REG_MULTI_SZ )
nValueType := WIN_REG_SZ
ENDIF
cName := xValue
EXIT
ENDSWITCH

View File

@@ -201,8 +201,20 @@ HB_FUNC( WIN_REGSETVALUEEX )
0,
dwType,
( const BYTE * ) &nSpace,
sizeof( REG_DWORD ) ) == ERROR_SUCCESS );
sizeof( DWORD ) ) == ERROR_SUCCESS );
}
#if defined( REG_QWORD )
else if( dwType == REG_QWORD )
{
HB_U64 nSpace = ( HB_U64 ) hb_parnint( 5 );
hb_retl( RegSetValueEx( ( HKEY ) hb_parptr( 1 ),
lpKey,
0,
dwType,
( const BYTE * ) &nSpace,
sizeof( HB_U64 ) ) == ERROR_SUCCESS );
}
#endif
else if( dwType == REG_SZ ||
dwType == REG_EXPAND_SZ ||
dwType == REG_MULTI_SZ )

View File

@@ -21,6 +21,7 @@
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\doc\readme.txt"
!define MUI_ICON "harb_win.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall.ico"
SetDateSave on
SetDatablockOptimize on

View File

@@ -20,6 +20,7 @@ SetCompressor /solid lzma
!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
!define MUI_FINISHPAGE_SHOWREADME "$INSTDIR\doc\readme.txt"
!define MUI_ICON "..\harb_win.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall.ico"
SetDateSave on
SetDatablockOptimize on