I have solve a problem with Reg32() class under Vista.
Access to registry is sometimes not possible because
of access rights. To solve it if you want just read in registry,
you must update Reg32():New() with something like that :
Code: Select all
// Registry Specific Access Rights.
#define KEY_QUERY_VALUE 1 // 0x0001
#define KEY_SET_VALUE 2 // 0x0002
#define KEY_CREATE_SUB_KEY 4 // 0x0004
#define KEY_ENUMERATE_SUB_KEYS 8 // 0x0008
#define KEY_NOTIFY 16 // 0x0010
#define KEY_CREATE_LINK 32 // 0x0020
//----------------------------------------------------------------------------//
CLASS TReg32
DATA cRegKey, nKey, nHandle, nError, lError
METHOD New( nKey, cRegKey, lShowError, nRegistrySpecificAccessRights ) CONSTRUCTOR
METHOD Create( nKey, cRegKey ) CONSTRUCTOR
METHOD Get( cSubKey, uVar )
METHOD Set( cSubKey, uVar )
METHOD Close() INLINE If(::lError,,RegCloseKey( ::nHandle ))
ENDCLASS
//----------------------------------------------------------------------------//
METHOD New( nKey, cRegKey, lShowError, nRegistrySpecificAccessRights ) CLASS TReg32
local nReturn, nHandle := 0
DEFAULT cRegKey := ""
DEFAULT ::lError := .f.
#ifdef __XPP__
#undef New
#endif
#ifdef __XPP__
do case
case nKey == HKEY_CLASSES_ROOT
nKey = 1
case nKey == HKEY_CURRENT_USER
nKey = 2
case nKey == HKEY_LOCAL_MACHINE
nKey = 3
case nKey == HKEY_USERS
nKey = 4
case nKey == HKEY_PERFORMANCE_DATA
nKey = 5
case nKey == HKEY_CURRENT_CONFIG
nKey = 6
case nKey == HKEY_DYN_DATA
nKey = 7
endcase
#endif
#ifdef __CLIPPER__
::nError = RegOpenKeyEx( nKey, cRegKey,, IIF(nRegistrySpecificAccessRights = NIL, KEY_ALL_ACCESS, nRegistrySpecificAccessRights), @nHandle )
#else
::nError = RegOpenKeyExA( nKey, cRegKey,, IIF(nRegistrySpecificAccessRights = NIL, KEY_ALL_ACCESS, nRegistrySpecificAccessRights), @nHandle )
#endif
* IF ISCLIPPER()
* ::nError = RegOpenKeyEx( nKey, cRegKey,, KEY_ALL_ACCESS, @nHandle )
* ELSE
* ::nError = RegOpenKeyExA( nKey, cRegKey,, KEY_ALL_ACCESS, @nHandle )
* ENDIF
::cRegKey = cRegKey
::nHandle = nHandle
return Self
//----------------------------------------------------------------------------//
I think it would be better to give the default
to KEY_QUERY_VALUE instead KEY_ALL_ACCESS.
On Vista this i very nice for me.
Regards,