1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: palmos/registry.cpp
3 // Purpose: implementation of registry classes and functions
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows licence
10 // TODO: - parsing of registry key names
11 // - support of other (than REG_SZ/REG_DWORD) registry types
12 // - add high level functions (RegisterOleServer, ...)
13 ///////////////////////////////////////////////////////////////////////////////
15 // This really doesn't apply to the Palm OS platform. It would be better to
16 // support the Palm OS preference database instead.
19 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
20 #pragma implementation "registry.h"
23 // for compilers that support precompilation, includes "wx.h".
24 #include "wx/wxprec.h"
30 // other wxWidgets headers
31 #include "wx/string.h"
35 #include "wx/palmos/wrapwin.h"
38 #include <stdlib.h> // for _MAX_PATH
45 #define HKEY_DEFINED // already defined in windows.h
46 #include "wx/palmos/registry.h"
48 // some registry functions don't like signed chars
49 typedef unsigned char *RegString
;
51 // ----------------------------------------------------------------------------
53 // ----------------------------------------------------------------------------
55 // the registry name separator (perhaps one day MS will change it to '/' ;-)
56 #define REG_SEPARATOR wxT('\\')
58 // useful for Windows programmers: makes somewhat more clear all these zeroes
59 // being passed to Windows APIs
62 // ----------------------------------------------------------------------------
64 // ----------------------------------------------------------------------------
66 // const_cast<> is not yet supported by all compilers
67 #define CONST_CAST ((wxRegKey *)this)->
69 // and neither is mutable which m_dwLastError should be
70 #define m_dwLastError CONST_CAST m_dwLastError
72 // ----------------------------------------------------------------------------
73 // non member functions
74 // ----------------------------------------------------------------------------
76 // ============================================================================
77 // implementation of wxRegKey class
78 // ============================================================================
80 // ----------------------------------------------------------------------------
81 // static functions and variables
82 // ----------------------------------------------------------------------------
84 const size_t wxRegKey::nStdKeys
= WXSIZEOF(aStdKeys
);
86 // @@ should take a `StdKey key', but as it's often going to be used in loops
87 // it would require casts in user code.
88 const wxChar
*wxRegKey::GetStdKeyName(size_t key
)
90 // return empty string if key is invalid
91 wxCHECK_MSG( key
< nStdKeys
, wxEmptyString
, wxT("invalid key in wxRegKey::GetStdKeyName") );
93 return aStdKeys
[key
].szName
;
96 const wxChar
*wxRegKey::GetStdKeyShortName(size_t key
)
98 // return empty string if key is invalid
99 wxCHECK( key
< nStdKeys
, wxEmptyString
);
101 return aStdKeys
[key
].szShortName
;
104 wxRegKey::StdKey
wxRegKey::ExtractKeyName(wxString
& strKey
)
106 wxString strRoot
= strKey
.BeforeFirst(REG_SEPARATOR
);
110 for ( ui
= 0; ui
< nStdKeys
; ui
++ ) {
111 if ( strRoot
.CmpNoCase(aStdKeys
[ui
].szName
) == 0 ||
112 strRoot
.CmpNoCase(aStdKeys
[ui
].szShortName
) == 0 ) {
113 hRootKey
= aStdKeys
[ui
].hkey
;
118 if ( ui
== nStdKeys
) {
119 wxFAIL_MSG(wxT("invalid key prefix in wxRegKey::ExtractKeyName."));
121 hRootKey
= HKEY_CLASSES_ROOT
;
124 strKey
= strKey
.After(REG_SEPARATOR
);
125 if ( !strKey
.IsEmpty() && strKey
.Last() == REG_SEPARATOR
)
126 strKey
.Truncate(strKey
.Len() - 1);
129 return (wxRegKey::StdKey
)(int)hRootKey
;
132 wxRegKey::StdKey
wxRegKey::GetStdKeyFromHkey(WXHKEY hkey
)
134 for ( size_t ui
= 0; ui
< nStdKeys
; ui
++ ) {
135 if ( (int) aStdKeys
[ui
].hkey
== (int) hkey
)
139 wxFAIL_MSG(wxT("non root hkey passed to wxRegKey::GetStdKeyFromHkey."));
144 // ----------------------------------------------------------------------------
146 // ----------------------------------------------------------------------------
150 m_hRootKey
= (WXHKEY
) aStdKeys
[HKCR
].hkey
;
155 wxRegKey::wxRegKey(const wxString
& strKey
) : m_strKey(strKey
)
157 m_hRootKey
= (WXHKEY
) aStdKeys
[ExtractKeyName(m_strKey
)].hkey
;
162 // parent is a predefined (and preopened) key
163 wxRegKey::wxRegKey(StdKey keyParent
, const wxString
& strKey
) : m_strKey(strKey
)
165 RemoveTrailingSeparator(m_strKey
);
166 m_hRootKey
= (WXHKEY
) aStdKeys
[keyParent
].hkey
;
171 // parent is a normal regkey
172 wxRegKey::wxRegKey(const wxRegKey
& keyParent
, const wxString
& strKey
)
173 : m_strKey(keyParent
.m_strKey
)
175 // combine our name with parent's to get the full name
176 if ( !m_strKey
.IsEmpty() &&
177 (strKey
.IsEmpty() || strKey
[0] != REG_SEPARATOR
) ) {
178 m_strKey
+= REG_SEPARATOR
;
182 RemoveTrailingSeparator(m_strKey
);
184 m_hRootKey
= keyParent
.m_hRootKey
;
189 // dtor closes the key releasing system resource
190 wxRegKey::~wxRegKey()
195 // ----------------------------------------------------------------------------
196 // change the key name/hkey
197 // ----------------------------------------------------------------------------
199 // set the full key name
200 void wxRegKey::SetName(const wxString
& strKey
)
205 m_hRootKey
= (WXHKEY
) aStdKeys
[ExtractKeyName(m_strKey
)].hkey
;
208 // the name is relative to the parent key
209 void wxRegKey::SetName(StdKey keyParent
, const wxString
& strKey
)
214 RemoveTrailingSeparator(m_strKey
);
215 m_hRootKey
= (WXHKEY
) aStdKeys
[keyParent
].hkey
;
218 // the name is relative to the parent key
219 void wxRegKey::SetName(const wxRegKey
& keyParent
, const wxString
& strKey
)
223 // combine our name with parent's to get the full name
225 // NB: this method is called by wxRegConfig::SetPath() which is a performance
226 // critical function and so it preallocates space for our m_strKey to
227 // gain some speed - this is why we only use += here and not = which
228 // would just free the prealloc'd buffer and would have to realloc it the
231 m_strKey
+= keyParent
.m_strKey
;
232 if ( !strKey
.IsEmpty() && strKey
[0] != REG_SEPARATOR
)
233 m_strKey
+= REG_SEPARATOR
;
236 RemoveTrailingSeparator(m_strKey
);
238 m_hRootKey
= keyParent
.m_hRootKey
;
241 // hKey should be opened and will be closed in wxRegKey dtor
242 void wxRegKey::SetHkey(WXHKEY hKey
)
249 // ----------------------------------------------------------------------------
250 // info about the key
251 // ----------------------------------------------------------------------------
253 // returns TRUE if the key exists
254 bool wxRegKey::Exists() const
256 // opened key has to exist, try to open it if not done yet
257 return IsOpened() ? TRUE
: KeyExists(m_hRootKey
, m_strKey
);
260 // returns the full name of the key (prefix is abbreviated if bShortPrefix)
261 wxString
wxRegKey::GetName(bool bShortPrefix
) const
263 StdKey key
= GetStdKeyFromHkey((WXHKEY
) m_hRootKey
);
264 wxString str
= bShortPrefix
? aStdKeys
[key
].szShortName
265 : aStdKeys
[key
].szName
;
266 if ( !m_strKey
.IsEmpty() )
267 str
<< _T("\\") << m_strKey
;
272 bool wxRegKey::GetKeyInfo(size_t *pnSubKeys
,
275 size_t *pnMaxValueLen
) const
277 // old gcc headers incorrectly prototype RegQueryInfoKey()
278 #if defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__)
279 #define REG_PARAM (size_t *)
281 #define REG_PARAM (LPDWORD)
284 // it might be unexpected to some that this function doesn't open the key
285 wxASSERT_MSG( IsOpened(), _T("key should be opened in GetKeyInfo") );
287 m_dwLastError
= ::RegQueryInfoKey
291 NULL
, // (ptr to) size of class name buffer
294 pnSubKeys
, // [out] number of subkeys
296 pnMaxKeyLen
, // [out] max length of a subkey name
297 NULL
, // longest subkey class name
299 pnValues
, // [out] number of values
301 pnMaxValueLen
, // [out] max length of a value name
302 NULL
, // longest value data
303 NULL
, // security descriptor
304 NULL
// time of last modification
309 if ( m_dwLastError
!= ERROR_SUCCESS
) {
310 wxLogSysError(m_dwLastError
, _("Can't get info about registry key '%s'"),
318 // ----------------------------------------------------------------------------
320 // ----------------------------------------------------------------------------
322 // opens key (it's not an error to call Open() on an already opened key)
323 bool wxRegKey::Open(AccessMode mode
)
329 m_dwLastError
= ::RegOpenKeyEx
334 mode
== Read
? KEY_READ
: KEY_ALL_ACCESS
,
338 if ( m_dwLastError
!= ERROR_SUCCESS
)
340 wxLogSysError(m_dwLastError
, _("Can't open registry key '%s'"),
345 m_hKey
= (WXHKEY
) tmpKey
;
349 // creates key, failing if it exists and !bOkIfExists
350 bool wxRegKey::Create(bool bOkIfExists
)
352 // check for existence only if asked (i.e. order is important!)
353 if ( !bOkIfExists
&& Exists() )
362 m_dwLastError
= RegCreateKeyEx((HKEY
) m_hRootKey
, m_strKey
,
364 NULL
, // class string
371 m_dwLastError
= RegCreateKey((HKEY
) m_hRootKey
, m_strKey
, &tmpKey
);
373 if ( m_dwLastError
!= ERROR_SUCCESS
) {
374 wxLogSysError(m_dwLastError
, _("Can't create registry key '%s'"),
380 m_hKey
= (WXHKEY
) tmpKey
;
385 // close the key, it's not an error to call it when not opened
386 bool wxRegKey::Close()
389 m_dwLastError
= RegCloseKey((HKEY
) m_hKey
);
392 if ( m_dwLastError
!= ERROR_SUCCESS
) {
393 wxLogSysError(m_dwLastError
, _("Can't close registry key '%s'"),
403 bool wxRegKey::RenameValue(const wxChar
*szValueOld
, const wxChar
*szValueNew
)
406 if ( HasValue(szValueNew
) ) {
407 wxLogError(_("Registry value '%s' already exists."), szValueNew
);
413 !CopyValue(szValueOld
, *this, szValueNew
) ||
414 !DeleteValue(szValueOld
) ) {
415 wxLogError(_("Failed to rename registry value '%s' to '%s'."),
416 szValueOld
, szValueNew
);
424 bool wxRegKey::CopyValue(const wxChar
*szValue
,
426 const wxChar
*szValueNew
)
429 // by default, use the same name
430 szValueNew
= szValue
;
433 switch ( GetValueType(szValue
) ) {
437 return QueryValue(szValue
, strVal
) &&
438 keyDst
.SetValue(szValueNew
, strVal
);
442 /* case Type_Dword_little_endian: == Type_Dword */
445 return QueryValue(szValue
, &dwVal
) &&
446 keyDst
.SetValue(szValueNew
, dwVal
);
449 // these types are unsupported because I am not sure about how
450 // exactly they should be copied and because they shouldn't
451 // occur among the application keys (supposedly created with
455 case Type_Expand_String
:
457 case Type_Dword_big_endian
:
459 case Type_Multi_String
:
460 case Type_Resource_list
:
461 case Type_Full_resource_descriptor
:
462 case Type_Resource_requirements_list
:
465 wxLogError(_("Can't copy values of unsupported type %d."),
466 GetValueType(szValue
));
471 bool wxRegKey::Rename(const wxChar
*szNewName
)
473 wxCHECK_MSG( !!m_strKey
, FALSE
, _T("registry hives can't be renamed") );
476 wxLogError(_("Registry key '%s' does not exist, cannot rename it."),
482 // do we stay in the same hive?
483 bool inSameHive
= !wxStrchr(szNewName
, REG_SEPARATOR
);
485 // construct the full new name of the key
489 // rename the key to the new name under the same parent
490 wxString strKey
= m_strKey
.BeforeLast(REG_SEPARATOR
);
492 // don't add '\\' in the start if strFullNewName is empty
493 strKey
+= REG_SEPARATOR
;
498 keyDst
.SetName(GetStdKeyFromHkey(m_hRootKey
), strKey
);
501 // this is the full name already
502 keyDst
.SetName(szNewName
);
505 bool ok
= keyDst
.Create(FALSE
/* fail if alredy exists */);
507 wxLogError(_("Registry key '%s' already exists."),
508 GetFullName(&keyDst
));
511 ok
= Copy(keyDst
) && DeleteSelf();
515 wxLogError(_("Failed to rename the registry key '%s' to '%s'."),
516 GetFullName(this), GetFullName(&keyDst
));
519 m_hRootKey
= keyDst
.m_hRootKey
;
520 m_strKey
= keyDst
.m_strKey
;
526 bool wxRegKey::Copy(const wxChar
*szNewName
)
528 // create the new key first
529 wxRegKey
keyDst(szNewName
);
530 bool ok
= keyDst
.Create(FALSE
/* fail if alredy exists */);
534 // we created the dest key but copying to it failed - delete it
536 (void)keyDst
.DeleteSelf();
543 bool wxRegKey::Copy(wxRegKey
& keyDst
)
547 // copy all sub keys to the new location
550 bool bCont
= GetFirstKey(strKey
, lIndex
);
551 while ( ok
&& bCont
) {
552 wxRegKey
key(*this, strKey
);
554 keyName
<< GetFullName(&keyDst
) << REG_SEPARATOR
<< strKey
;
555 ok
= key
.Copy((const wxChar
*) keyName
);
558 bCont
= GetNextKey(strKey
, lIndex
);
563 bCont
= GetFirstValue(strVal
, lIndex
);
564 while ( ok
&& bCont
) {
565 ok
= CopyValue(strVal
, keyDst
);
568 wxLogSysError(m_dwLastError
,
569 _("Failed to copy registry value '%s'"),
573 bCont
= GetNextValue(strVal
, lIndex
);
578 wxLogError(_("Failed to copy the contents of registry key '%s' to '%s'."), GetFullName(this), GetFullName(&keyDst
));
584 // ----------------------------------------------------------------------------
585 // delete keys/values
586 // ----------------------------------------------------------------------------
587 bool wxRegKey::DeleteSelf()
592 // it already doesn't exist - ok!
597 // prevent a buggy program from erasing one of the root registry keys or an
598 // immediate subkey (i.e. one which doesn't have '\\' inside) of any other
599 // key except HKCR (HKCR has some "deleteable" subkeys)
600 if ( m_strKey
.IsEmpty() ||
601 ((m_hRootKey
!= (WXHKEY
) aStdKeys
[HKCR
].hkey
) &&
602 (m_strKey
.Find(REG_SEPARATOR
) == wxNOT_FOUND
)) ) {
603 wxLogError(_("Registry key '%s' is needed for normal system operation,\ndeleting it will leave your system in unusable state:\noperation aborted."), GetFullName(this));
608 // we can't delete keys while enumerating because it confuses GetNextKey, so
609 // we first save the key names and then delete them all
610 wxArrayString astrSubkeys
;
614 bool bCont
= GetFirstKey(strKey
, lIndex
);
616 astrSubkeys
.Add(strKey
);
618 bCont
= GetNextKey(strKey
, lIndex
);
621 size_t nKeyCount
= astrSubkeys
.Count();
622 for ( size_t nKey
= 0; nKey
< nKeyCount
; nKey
++ ) {
623 wxRegKey
key(*this, astrSubkeys
[nKey
]);
624 if ( !key
.DeleteSelf() )
628 // now delete this key itself
631 m_dwLastError
= RegDeleteKey((HKEY
) m_hRootKey
, m_strKey
);
632 // deleting a key which doesn't exist is not considered an error
633 if ( m_dwLastError
!= ERROR_SUCCESS
&&
634 m_dwLastError
!= ERROR_FILE_NOT_FOUND
) {
635 wxLogSysError(m_dwLastError
, _("Can't delete key '%s'"),
643 bool wxRegKey::DeleteKey(const wxChar
*szKey
)
648 wxRegKey
key(*this, szKey
);
649 return key
.DeleteSelf();
652 bool wxRegKey::DeleteValue(const wxChar
*szValue
)
657 m_dwLastError
= RegDeleteValue((HKEY
) m_hKey
, WXSTRINGCAST szValue
);
659 // deleting a value which doesn't exist is not considered an error
660 if ( (m_dwLastError
!= ERROR_SUCCESS
) &&
661 (m_dwLastError
!= ERROR_FILE_NOT_FOUND
) ) {
662 wxLogSysError(m_dwLastError
, _("Can't delete value '%s' from key '%s'"),
663 szValue
, GetName().c_str());
670 // ----------------------------------------------------------------------------
671 // access to values and subkeys
672 // ----------------------------------------------------------------------------
674 // return TRUE if value exists
675 bool wxRegKey::HasValue(const wxChar
*szValue
) const
677 // this function should be silent, so suppress possible messages from Open()
680 if ( !CONST_CAST
Open() )
683 LONG dwRet
= ::RegQueryValueEx((HKEY
) m_hKey
,
684 WXSTRINGCAST szValue
,
687 return dwRet
== ERROR_SUCCESS
;
690 // returns TRUE if this key has any values
691 bool wxRegKey::HasValues() const
693 // suppress possible messages from GetFirstValue()
696 // just call GetFirstValue with dummy parameters
699 return CONST_CAST
GetFirstValue(str
, l
);
702 // returns TRUE if this key has any subkeys
703 bool wxRegKey::HasSubkeys() const
705 // suppress possible messages from GetFirstKey()
708 // just call GetFirstKey with dummy parameters
711 return CONST_CAST
GetFirstKey(str
, l
);
714 // returns TRUE if given subkey exists
715 bool wxRegKey::HasSubKey(const wxChar
*szKey
) const
717 // this function should be silent, so suppress possible messages from Open()
720 if ( !CONST_CAST
Open() )
723 return KeyExists(m_hKey
, szKey
);
726 wxRegKey::ValueType
wxRegKey::GetValueType(const wxChar
*szValue
) const
728 if ( ! CONST_CAST
Open() )
732 m_dwLastError
= RegQueryValueEx((HKEY
) m_hKey
, WXSTRINGCAST szValue
, RESERVED
,
733 &dwType
, NULL
, NULL
);
734 if ( m_dwLastError
!= ERROR_SUCCESS
) {
735 wxLogSysError(m_dwLastError
, _("Can't read value of key '%s'"),
740 return (ValueType
)dwType
;
744 bool wxRegKey::SetValue(const wxChar
*szValue
, long lValue
)
746 if ( CONST_CAST
Open() ) {
747 m_dwLastError
= RegSetValueEx((HKEY
) m_hKey
, szValue
, (DWORD
) RESERVED
, REG_DWORD
,
748 (RegString
)&lValue
, sizeof(lValue
));
749 if ( m_dwLastError
== ERROR_SUCCESS
)
753 wxLogSysError(m_dwLastError
, _("Can't set value of '%s'"),
754 GetFullName(this, szValue
));
758 bool wxRegKey::QueryValue(const wxChar
*szValue
, long *plValue
) const
760 if ( CONST_CAST
Open() ) {
761 DWORD dwType
, dwSize
= sizeof(DWORD
);
762 RegString pBuf
= (RegString
)plValue
;
763 m_dwLastError
= RegQueryValueEx((HKEY
) m_hKey
, WXSTRINGCAST szValue
, RESERVED
,
764 &dwType
, pBuf
, &dwSize
);
765 if ( m_dwLastError
!= ERROR_SUCCESS
) {
766 wxLogSysError(m_dwLastError
, _("Can't read value of key '%s'"),
771 // check that we read the value of right type
772 wxASSERT_MSG( IsNumericValue(szValue
),
773 wxT("Type mismatch in wxRegKey::QueryValue().") );
784 bool wxRegKey::QueryValue(const wxChar
*szValue
,
788 if ( CONST_CAST
Open() ) {
790 // first get the type and size of the data
791 DWORD dwType
, dwSize
;
792 m_dwLastError
= RegQueryValueEx((HKEY
) m_hKey
, WXSTRINGCAST szValue
, RESERVED
,
793 &dwType
, NULL
, &dwSize
);
794 if ( m_dwLastError
== ERROR_SUCCESS
) {
796 // must treat this case specially as GetWriteBuf() doesn't like
797 // being called with 0 size
801 m_dwLastError
= RegQueryValueEx((HKEY
) m_hKey
,
802 WXSTRINGCAST szValue
,
805 (RegString
)(wxChar
*)wxStringBuffer(strValue
, dwSize
),
808 // expand the var expansions in the string unless disabled
810 if ( (dwType
== REG_EXPAND_SZ
) && !raw
)
812 DWORD dwExpSize
= ::ExpandEnvironmentStrings(strValue
, NULL
, 0);
813 bool ok
= dwExpSize
!= 0;
816 wxString strExpValue
;
817 ok
= ::ExpandEnvironmentStrings
820 wxStringBuffer(strExpValue
, dwExpSize
),
823 strValue
= strExpValue
;
828 wxLogLastError(_T("ExpandEnvironmentStrings"));
835 if ( m_dwLastError
== ERROR_SUCCESS
) {
836 // check that it was the right type
837 wxASSERT_MSG( !IsNumericValue(szValue
),
838 wxT("Type mismatch in wxRegKey::QueryValue().") );
845 wxLogSysError(m_dwLastError
, _("Can't read value of '%s'"),
846 GetFullName(this, szValue
));
850 bool wxRegKey::SetValue(const wxChar
*szValue
, const wxString
& strValue
)
852 if ( CONST_CAST
Open() ) {
853 m_dwLastError
= RegSetValueEx((HKEY
) m_hKey
, szValue
, (DWORD
) RESERVED
, REG_SZ
,
854 (RegString
)strValue
.c_str(),
855 (strValue
.Len() + 1)*sizeof(wxChar
));
856 if ( m_dwLastError
== ERROR_SUCCESS
)
860 wxLogSysError(m_dwLastError
, _("Can't set value of '%s'"),
861 GetFullName(this, szValue
));
865 wxString
wxRegKey::QueryDefaultValue() const
868 QueryValue(NULL
, str
);
872 // ----------------------------------------------------------------------------
874 // NB: all these functions require an index variable which allows to have
875 // several concurrently running indexations on the same key
876 // ----------------------------------------------------------------------------
878 bool wxRegKey::GetFirstValue(wxString
& strValueName
, long& lIndex
)
884 return GetNextValue(strValueName
, lIndex
);
887 bool wxRegKey::GetNextValue(wxString
& strValueName
, long& lIndex
) const
889 wxASSERT( IsOpened() );
891 // are we already at the end of enumeration?
895 wxChar szValueName
[1024]; // @@ use RegQueryInfoKey...
896 DWORD dwValueLen
= WXSIZEOF(szValueName
);
898 m_dwLastError
= RegEnumValue((HKEY
) m_hKey
, lIndex
++,
899 szValueName
, &dwValueLen
,
902 NULL
, // [out] buffer for value
903 NULL
); // [i/o] it's length
905 if ( m_dwLastError
!= ERROR_SUCCESS
) {
906 if ( m_dwLastError
== ERROR_NO_MORE_ITEMS
) {
907 m_dwLastError
= ERROR_SUCCESS
;
911 wxLogSysError(m_dwLastError
, _("Can't enumerate values of key '%s'"),
918 strValueName
= szValueName
;
923 bool wxRegKey::GetFirstKey(wxString
& strKeyName
, long& lIndex
)
929 return GetNextKey(strKeyName
, lIndex
);
932 bool wxRegKey::GetNextKey(wxString
& strKeyName
, long& lIndex
) const
934 wxASSERT( IsOpened() );
936 // are we already at the end of enumeration?
940 wxChar szKeyName
[_MAX_PATH
+ 1];
943 DWORD sizeName
= WXSIZEOF(szKeyName
);
944 m_dwLastError
= RegEnumKeyEx((HKEY
) m_hKey
, lIndex
++, szKeyName
, & sizeName
,
945 0, NULL
, NULL
, NULL
);
947 m_dwLastError
= RegEnumKey((HKEY
) m_hKey
, lIndex
++, szKeyName
, WXSIZEOF(szKeyName
));
950 if ( m_dwLastError
!= ERROR_SUCCESS
) {
951 if ( m_dwLastError
== ERROR_NO_MORE_ITEMS
) {
952 m_dwLastError
= ERROR_SUCCESS
;
956 wxLogSysError(m_dwLastError
, _("Can't enumerate subkeys of key '%s'"),
963 strKeyName
= szKeyName
;
967 // returns TRUE if the value contains a number (else it's some string)
968 bool wxRegKey::IsNumericValue(const wxChar
*szValue
) const
970 ValueType type
= GetValueType(szValue
);
973 /* case Type_Dword_little_endian: == Type_Dword */
974 case Type_Dword_big_endian
:
982 // ============================================================================
983 // implementation of global private functions
984 // ============================================================================
986 bool KeyExists(WXHKEY hRootKey
, const wxChar
*szKey
)
988 // don't close this key itself for the case of empty szKey!
989 if ( wxIsEmpty(szKey
) )
998 KEY_READ
, // we might not have enough rights for rw access
1000 ) == ERROR_SUCCESS
)
1002 ::RegCloseKey(hkeyDummy
);
1010 const wxChar
*GetFullName(const wxRegKey
*pKey
, const wxChar
*szValue
)
1012 static wxString s_str
;
1013 s_str
= pKey
->GetName();
1014 if ( !wxIsEmpty(szValue
) )
1015 s_str
<< wxT("\\") << szValue
;
1017 return s_str
.c_str();
1020 void RemoveTrailingSeparator(wxString
& str
)
1022 if ( !str
.IsEmpty() && str
.Last() == REG_SEPARATOR
)
1023 str
.Truncate(str
.Len() - 1);