]> git.saurik.com Git - wxWidgets.git/blob - src/msw/regconf.cpp
Applied BMP patch.
[wxWidgets.git] / src / msw / regconf.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: msw/regconf.cpp
3 // Purpose:
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 27.04.98
7 // RCS-ID: $Id$
8 // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "regconf.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include "wx/string.h"
25 #endif //WX_PRECOMP
26
27 #include "wx/event.h"
28 #include "wx/app.h"
29 #include "wx/log.h"
30
31 #if wxUSE_CONFIG
32
33 #include "wx/config.h"
34
35 #ifndef __WIN16__
36
37 #include "wx/msw/registry.h"
38 #include "wx/msw/regconf.h"
39
40 // ----------------------------------------------------------------------------
41 // constants
42 // ----------------------------------------------------------------------------
43
44 // we put our data in HKLM\SOFTWARE_KEY\appname
45 #define SOFTWARE_KEY wxString("Software\\")
46
47 // ----------------------------------------------------------------------------
48 // global functions
49 // ----------------------------------------------------------------------------
50
51 // get the value if the key is opened and it exists
52 bool TryGetValue(const wxRegKey& key, const wxString& str, wxString& strVal)
53 {
54 return key.IsOpened() && key.HasValue(str) && key.QueryValue(str, strVal);
55 }
56
57 bool TryGetValue(const wxRegKey& key, const wxString& str, long *plVal)
58 {
59 return key.IsOpened() && key.HasValue(str) && key.QueryValue(str, plVal);
60 }
61
62 // ============================================================================
63 // implementation
64 // ============================================================================
65
66 // ----------------------------------------------------------------------------
67 // ctor/dtor
68 // ----------------------------------------------------------------------------
69
70 // create the config object which stores its data under HKCU\vendor\app and, if
71 // style & wxCONFIG_USE_GLOBAL_FILE, under HKLM\vendor\app
72 wxRegConfig::wxRegConfig(const wxString& appName, const wxString& vendorName,
73 const wxString& strLocal, const wxString& strGlobal,
74 long style)
75 : wxConfigBase(appName, vendorName, strLocal, strGlobal, style)
76 {
77 wxString strRoot;
78
79 bool bDoUseGlobal = (style & wxCONFIG_USE_GLOBAL_FILE) != 0;
80
81 // the convention is to put the programs keys under <vendor>\<appname>
82 // (but it can be overriden by specifying the pathes explicitly in strLocal
83 // and/or strGlobal)
84 if ( strLocal.IsEmpty() || (strGlobal.IsEmpty() && bDoUseGlobal) )
85 {
86 if ( vendorName.IsEmpty() )
87 {
88 if ( wxTheApp )
89 strRoot = wxTheApp->GetVendorName();
90 }
91 else
92 {
93 strRoot = vendorName;
94 }
95
96 // no '\\' needed if no vendor name
97 if ( !strRoot.IsEmpty() )
98 {
99 strRoot += '\\';
100 }
101
102 if ( appName.IsEmpty() )
103 {
104 wxCHECK_RET( wxTheApp, wxT("No application name in wxRegConfig ctor!") );
105 strRoot << wxTheApp->GetAppName();
106 }
107 else
108 {
109 strRoot << appName;
110 }
111 }
112 //else: we don't need to do all the complicated stuff above
113
114 wxString str = strLocal.IsEmpty() ? strRoot : strLocal;
115
116 // as we're going to change the name of these keys fairly often and as
117 // there are only few of wxRegConfig objects (usually 1), we can allow
118 // ourselves to be generous and spend some memory to significantly improve
119 // performance of SetPath()
120 static const size_t MEMORY_PREALLOC = 512;
121
122 m_keyLocalRoot.ReserveMemoryForName(MEMORY_PREALLOC);
123 m_keyLocal.ReserveMemoryForName(MEMORY_PREALLOC);
124
125 m_keyLocalRoot.SetName(wxRegKey::HKCU, SOFTWARE_KEY + str);
126 m_keyLocal.SetName(m_keyLocalRoot, _T(""));
127
128 if ( bDoUseGlobal )
129 {
130 str = strGlobal.IsEmpty() ? strRoot : strGlobal;
131
132 m_keyGlobalRoot.ReserveMemoryForName(MEMORY_PREALLOC);
133 m_keyGlobal.ReserveMemoryForName(MEMORY_PREALLOC);
134
135 m_keyGlobalRoot.SetName(wxRegKey::HKLM, SOFTWARE_KEY + str);
136 m_keyGlobal.SetName(m_keyGlobalRoot, _T(""));
137 }
138
139 // Create() will Open() if key already exists
140 m_keyLocalRoot.Create();
141
142 // as it's the same key, Open() shouldn't fail (i.e. no need for Create())
143 m_keyLocal.Open();
144
145 // OTOH, this key may perfectly not exist, so suppress error messages the call
146 // to Open() might generate
147 if ( bDoUseGlobal )
148 {
149 wxLogNull nolog;
150 m_keyGlobalRoot.Open();
151 m_keyGlobal.Open();
152 }
153 }
154
155 wxRegConfig::~wxRegConfig()
156 {
157 // nothing to do - key will be closed in their dtors
158 }
159
160 // ----------------------------------------------------------------------------
161 // path management
162 // ----------------------------------------------------------------------------
163
164 // this function is called a *lot* of times (as I learned after seeing from
165 // profiler output that it is called ~12000 times from Mahogany start up code!)
166 // so it is important to optimize it - in particular, avoid using generic
167 // string functions here and do everything manually because it is faster
168 //
169 // I still kept the old version to be able to check that the optimized code has
170 // the same output as the non optimized version.
171 void wxRegConfig::SetPath(const wxString& strPath)
172 {
173 // remember the old path
174 wxString strOldPath = m_strPath;
175
176 #ifdef WX_DEBUG_SET_PATH // non optimized version kept here for testing
177 wxString m_strPathAlt;
178
179 {
180 wxArrayString aParts;
181
182 // because GetPath() returns "" when we're at root, we must understand
183 // empty string as "/"
184 if ( strPath.IsEmpty() || (strPath[0] == wxCONFIG_PATH_SEPARATOR) ) {
185 // absolute path
186 wxSplitPath(aParts, strPath);
187 }
188 else {
189 // relative path, combine with current one
190 wxString strFullPath = GetPath();
191 strFullPath << wxCONFIG_PATH_SEPARATOR << strPath;
192 wxSplitPath(aParts, strFullPath);
193 }
194
195 // recombine path parts in one variable
196 wxString strRegPath;
197 m_strPathAlt.Empty();
198 for ( size_t n = 0; n < aParts.Count(); n++ ) {
199 strRegPath << '\\' << aParts[n];
200 m_strPathAlt << wxCONFIG_PATH_SEPARATOR << aParts[n];
201 }
202 }
203 #endif // 0
204
205 // check for the most common case first
206 if ( strPath.empty() )
207 {
208 m_strPath = wxCONFIG_PATH_SEPARATOR;
209 }
210 else // not root
211 {
212 // construct the full path
213 wxString strFullPath;
214 if ( strPath[0u] == wxCONFIG_PATH_SEPARATOR )
215 {
216 // absolute path
217 strFullPath = strPath;
218 }
219 else // relative path
220 {
221 strFullPath.reserve(2*m_strPath.length());
222
223 strFullPath << m_strPath << wxCONFIG_PATH_SEPARATOR << strPath;
224 }
225
226 // simplify it: we need to handle ".." here
227
228 // count the total number of slashes we have to know if we can go upper
229 size_t totalSlashes = 0;
230
231 // position of the last slash to be able to backtrack to it quickly if
232 // needed, but we set it to -1 if we don't have a valid position
233 //
234 // we only remember the last position which means that we handle ".."
235 // quite efficiently but not "../.." - however the latter should be
236 // much more rare, so it is probably ok
237 int posLastSlash = -1;
238
239 const wxChar *src = strFullPath.c_str();
240 size_t len = strFullPath.length();
241 const wxChar *end = src + len;
242
243 wxChar *dst = m_strPath.GetWriteBuf(len);
244 wxChar *start = dst;
245
246 for ( ; src < end; src++, dst++ )
247 {
248 if ( *src == wxCONFIG_PATH_SEPARATOR )
249 {
250 // check for "/.."
251
252 // note that we don't have to check for src < end here as
253 // *end == 0 so can't be '.'
254 if ( src[1] == _T('.') && src[2] == _T('.') &&
255 (src + 3 == end || src[3] == wxCONFIG_PATH_SEPARATOR) )
256 {
257 if ( !totalSlashes )
258 {
259 wxLogWarning(_("'%s' has extra '..', ignored."),
260 strFullPath.c_str());
261 }
262 else // return to the previous path component
263 {
264 // do we already have its position?
265 if ( posLastSlash == -1 )
266 {
267 // no, find it: note that we are sure to have one
268 // because totalSlashes > 0 so we don't have to
269 // check the boundary condition below
270
271 // this is more efficient than strrchr()
272 while ( *dst != wxCONFIG_PATH_SEPARATOR )
273 {
274 dst--;
275 }
276 }
277 else // the position of last slash was stored
278 {
279 // go directly there
280 dst = start + posLastSlash;
281
282 // invalidate posLastSlash
283 posLastSlash = -1;
284 }
285
286 // this shouldn't happen
287 wxASSERT_MSG( *dst == wxCONFIG_PATH_SEPARATOR,
288 _T("error in wxRegConfig::SetPath") );
289
290 // we killed one
291 totalSlashes--;
292 }
293
294 // skip both dots
295 src += 2;
296 }
297 else // not "/.."
298 {
299 if ( (dst == start) || (dst[-1] != wxCONFIG_PATH_SEPARATOR) )
300 {
301 *dst = wxCONFIG_PATH_SEPARATOR;
302
303 posLastSlash = dst - start;
304
305 totalSlashes++;
306 }
307 //else: nothing to do, we squeeze several subseuquent
308 // slashes into one
309 }
310 }
311 else // normal character
312 {
313 // just copy
314 *dst = *src;
315 }
316 }
317
318 // NUL terminate the string
319 if ( dst[-1] == wxCONFIG_PATH_SEPARATOR && (dst != start + 1) )
320 {
321 // if it has a trailing slash we remove it unless it is the only
322 // string character
323 dst--;
324 }
325
326 *dst = _T('\0');
327
328 m_strPath.UngetWriteBuf(dst - start);
329 }
330
331 #ifdef WX_DEBUG_SET_PATH
332 wxASSERT( m_strPath == m_strPathAlt );
333 #endif
334
335 if ( m_strPath == strOldPath )
336 return;
337
338 // registry APIs want backslashes instead of slashes
339 wxString strRegPath;
340 size_t len = m_strPath.length();
341
342 const wxChar *src = m_strPath.c_str();
343 wxChar *dst = strRegPath.GetWriteBuf(len);
344
345 const wxChar *end = src + len;
346 for ( ; src < end; src++, dst++ )
347 {
348 if ( *src == wxCONFIG_PATH_SEPARATOR )
349 *dst = _T('\\');
350 else
351 *dst = *src;
352 }
353
354 strRegPath.UngetWriteBuf(len);
355
356 // this is not needed any longer as we don't create keys unnecessarily any
357 // more (now it is done on demand, i.e. only when they're going to contain
358 // something)
359 #if 0
360 // as we create the registry key when SetPath(key) is done, we can be left
361 // with plenty of empty keys if this was only done to try to read some
362 // value which, in fact, doesn't exist - to prevent this from happening we
363 // automatically delete the old key if it was empty
364 if ( m_keyLocal.Exists() && LocalKey().IsEmpty() )
365 {
366 m_keyLocal.DeleteSelf();
367 }
368 #endif // 0
369
370 // change current key(s)
371 m_keyLocal.SetName(m_keyLocalRoot, strRegPath);
372 m_keyGlobal.SetName(m_keyGlobalRoot, strRegPath);
373
374 // don't create it right now, wait until it is accessed
375 //m_keyLocal.Create();
376
377 wxLogNull nolog;
378 m_keyGlobal.Open();
379 }
380
381 // ----------------------------------------------------------------------------
382 // enumeration (works only with current group)
383 // ----------------------------------------------------------------------------
384
385 /*
386 We want to enumerate all local keys/values after the global ones, but, of
387 course, we don't want to repeat a key which appears locally as well as
388 globally twice.
389
390 We use the 15th bit of lIndex for distinction between global and local.
391 */
392
393 #define LOCAL_MASK 0x8000
394 #define IS_LOCAL_INDEX(l) (((l) & LOCAL_MASK) != 0)
395
396 bool wxRegConfig::GetFirstGroup(wxString& str, long& lIndex) const
397 {
398 lIndex = 0;
399 return GetNextGroup(str, lIndex);
400 }
401
402 bool wxRegConfig::GetNextGroup(wxString& str, long& lIndex) const
403 {
404 // are we already enumerating local entries?
405 if ( m_keyGlobal.IsOpened() && !IS_LOCAL_INDEX(lIndex) ) {
406 // try to find a global entry which doesn't appear locally
407 while ( m_keyGlobal.GetNextKey(str, lIndex) ) {
408 if ( !m_keyLocal.Exists() || !LocalKey().HasSubKey(str) ) {
409 // ok, found one - return it
410 return TRUE;
411 }
412 }
413
414 // no more global entries
415 lIndex |= LOCAL_MASK;
416 }
417
418 // if we don't have the key at all, don't try to enumerate anything under it
419 if ( !m_keyLocal.Exists() )
420 return FALSE;
421
422 // much easier with local entries: get the next one we find
423 // (don't forget to clear our flag bit and set it again later)
424 lIndex &= ~LOCAL_MASK;
425 bool bOk = LocalKey().GetNextKey(str, lIndex);
426 lIndex |= LOCAL_MASK;
427
428 return bOk;
429 }
430
431 bool wxRegConfig::GetFirstEntry(wxString& str, long& lIndex) const
432 {
433 lIndex = 0;
434 return GetNextEntry(str, lIndex);
435 }
436
437 bool wxRegConfig::GetNextEntry(wxString& str, long& lIndex) const
438 {
439 // are we already enumerating local entries?
440 if ( m_keyGlobal.IsOpened() && !IS_LOCAL_INDEX(lIndex) ) {
441 // try to find a global entry which doesn't appear locally
442 while ( m_keyGlobal.GetNextValue(str, lIndex) ) {
443 if ( !m_keyLocal.Exists() || !LocalKey().HasValue(str) ) {
444 // ok, found one - return it
445 return TRUE;
446 }
447 }
448
449 // no more global entries
450 lIndex |= LOCAL_MASK;
451 }
452
453 // if we don't have the key at all, don't try to enumerate anything under it
454 if ( !m_keyLocal.Exists() )
455 return FALSE;
456
457 // much easier with local entries: get the next one we find
458 // (don't forget to clear our flag bit and set it again later)
459 lIndex &= ~LOCAL_MASK;
460 bool bOk = LocalKey().GetNextValue(str, lIndex);
461 lIndex |= LOCAL_MASK;
462
463 return bOk;
464 }
465
466 size_t wxRegConfig::GetNumberOfEntries(bool bRecursive) const
467 {
468 size_t nEntries = 0;
469
470 // dummy vars
471 wxString str;
472 long l;
473 bool bCont = ((wxRegConfig*)this)->GetFirstEntry(str, l);
474 while ( bCont ) {
475 nEntries++;
476
477 bCont = ((wxRegConfig*)this)->GetNextEntry(str, l);
478 }
479
480 return nEntries;
481 }
482
483 size_t wxRegConfig::GetNumberOfGroups(bool bRecursive) const
484 {
485 size_t nGroups = 0;
486
487 // dummy vars
488 wxString str;
489 long l;
490 bool bCont = ((wxRegConfig*)this)->GetFirstGroup(str, l);
491 while ( bCont ) {
492 nGroups++;
493
494 bCont = ((wxRegConfig*)this)->GetNextGroup(str, l);
495 }
496
497 return nGroups;
498 }
499
500 // ----------------------------------------------------------------------------
501 // tests for existence
502 // ----------------------------------------------------------------------------
503
504 bool wxRegConfig::HasGroup(const wxString& key) const
505 {
506 wxConfigPathChanger path(this, key);
507
508 wxString strName(path.Name());
509
510 return (m_keyLocal.Exists() && LocalKey().HasSubKey(strName)) ||
511 m_keyGlobal.HasSubKey(strName);
512 }
513
514 bool wxRegConfig::HasEntry(const wxString& key) const
515 {
516 wxConfigPathChanger path(this, key);
517
518 wxString strName(path.Name());
519
520 return (m_keyLocal.Exists() && LocalKey().HasValue(strName)) ||
521 m_keyGlobal.HasValue(strName);
522 }
523
524 wxConfigBase::EntryType wxRegConfig::GetEntryType(const wxString& key) const
525 {
526 wxConfigPathChanger path(this, key);
527
528 wxString strName(path.Name());
529
530 bool isNumeric;
531 if ( m_keyLocal.Exists() && LocalKey().HasValue(strName) )
532 isNumeric = m_keyLocal.IsNumericValue(strName);
533 else if ( m_keyGlobal.HasValue(strName) )
534 isNumeric = m_keyGlobal.IsNumericValue(strName);
535 else
536 return wxConfigBase::Type_Unknown;
537
538 return isNumeric ? wxConfigBase::Type_Integer : wxConfigBase::Type_String;
539 }
540
541 // ----------------------------------------------------------------------------
542 // reading/writing
543 // ----------------------------------------------------------------------------
544
545 bool wxRegConfig::Read(const wxString& key, wxString *pStr) const
546 {
547 wxConfigPathChanger path(this, key);
548
549 bool bQueryGlobal = TRUE;
550
551 // if immutable key exists in global key we must check that it's not
552 // overriden by the local key with the same name
553 if ( IsImmutable(path.Name()) ) {
554 if ( TryGetValue(m_keyGlobal, path.Name(), *pStr) ) {
555 if ( m_keyLocal.Exists() && LocalKey().HasValue(path.Name()) ) {
556 wxLogWarning(wxT("User value for immutable key '%s' ignored."),
557 path.Name().c_str());
558 }
559 *pStr = wxConfigBase::ExpandEnvVars(*pStr);
560 return TRUE;
561 }
562 else {
563 // don't waste time - it's not there anyhow
564 bQueryGlobal = FALSE;
565 }
566 }
567
568 // first try local key
569 if ( (m_keyLocal.Exists() && TryGetValue(LocalKey(), path.Name(), *pStr)) ||
570 (bQueryGlobal && TryGetValue(m_keyGlobal, path.Name(), *pStr)) ) {
571 // nothing to do
572
573 *pStr = wxConfigBase::ExpandEnvVars(*pStr);
574 return TRUE;
575 }
576
577 return FALSE;
578 }
579
580 bool wxRegConfig::Read(const wxString& key, wxString *pStr,
581 const wxString& szDefault) const
582 {
583 wxConfigPathChanger path(this, key);
584
585 bool bQueryGlobal = TRUE;
586
587 // if immutable key exists in global key we must check that it's not
588 // overriden by the local key with the same name
589 if ( IsImmutable(path.Name()) ) {
590 if ( TryGetValue(m_keyGlobal, path.Name(), *pStr) ) {
591 if ( m_keyLocal.Exists() && LocalKey().HasValue(path.Name()) ) {
592 wxLogWarning(wxT("User value for immutable key '%s' ignored."),
593 path.Name().c_str());
594 }
595
596 return TRUE;
597 }
598 else {
599 // don't waste time - it's not there anyhow
600 bQueryGlobal = FALSE;
601 }
602 }
603
604 // first try local key
605 if ( (m_keyLocal.Exists() && TryGetValue(LocalKey(), path.Name(), *pStr)) ||
606 (bQueryGlobal && TryGetValue(m_keyGlobal, path.Name(), *pStr)) ) {
607 *pStr = wxConfigBase::ExpandEnvVars(*pStr);
608 return TRUE;
609 }
610 else {
611 if ( IsRecordingDefaults() ) {
612 ((wxRegConfig*)this)->Write(key, szDefault);
613 }
614
615 // default value
616 *pStr = szDefault;
617 }
618
619 *pStr = wxConfigBase::ExpandEnvVars(*pStr);
620
621 return FALSE;
622 }
623
624 bool wxRegConfig::Read(const wxString& key, long *plResult) const
625 {
626 wxConfigPathChanger path(this, key);
627
628 bool bQueryGlobal = TRUE;
629
630 // if immutable key exists in global key we must check that it's not
631 // overriden by the local key with the same name
632 if ( IsImmutable(path.Name()) ) {
633 if ( TryGetValue(m_keyGlobal, path.Name(), plResult) ) {
634 if ( m_keyLocal.Exists() && LocalKey().HasValue(path.Name()) ) {
635 wxLogWarning(wxT("User value for immutable key '%s' ignored."),
636 path.Name().c_str());
637 }
638
639 return TRUE;
640 }
641 else {
642 // don't waste time - it's not there anyhow
643 bQueryGlobal = FALSE;
644 }
645 }
646
647 // first try local key
648 if ( (m_keyLocal.Exists() && TryGetValue(LocalKey(), path.Name(), plResult)) ||
649 (bQueryGlobal && TryGetValue(m_keyGlobal, path.Name(), plResult)) ) {
650 return TRUE;
651 }
652 return FALSE;
653 }
654
655 bool wxRegConfig::Write(const wxString& key, const wxString& szValue)
656 {
657 wxConfigPathChanger path(this, key);
658
659 if ( IsImmutable(path.Name()) ) {
660 wxLogError(wxT("Can't change immutable entry '%s'."), path.Name().c_str());
661 return FALSE;
662 }
663
664 return LocalKey().SetValue(path.Name(), szValue);
665 }
666
667 bool wxRegConfig::Write(const wxString& key, long lValue)
668 {
669 wxConfigPathChanger path(this, key);
670
671 if ( IsImmutable(path.Name()) ) {
672 wxLogError(wxT("Can't change immutable entry '%s'."), path.Name().c_str());
673 return FALSE;
674 }
675
676 return LocalKey().SetValue(path.Name(), lValue);
677 }
678
679 // ----------------------------------------------------------------------------
680 // renaming
681 // ----------------------------------------------------------------------------
682
683 bool wxRegConfig::RenameEntry(const wxString& oldName, const wxString& newName)
684 {
685 // check that the old entry exists...
686 if ( !HasEntry(oldName) )
687 return FALSE;
688
689 // and that the new one doesn't
690 if ( HasEntry(newName) )
691 return FALSE;
692
693 // delete the old entry and create the new one - but do in the reverse
694 // order to not lose the data if Create() fails
695
696 bool ok;
697 if ( m_keyLocal.IsNumericValue(oldName) )
698 {
699 long val;
700 ok = m_keyLocal.QueryValue(oldName, &val) &&
701 m_keyLocal.SetValue(newName, val);
702 }
703 else
704 {
705 wxString val;
706 ok = m_keyLocal.QueryValue(oldName, val) &&
707 m_keyLocal.SetValue(newName, val);
708 }
709
710 if ( !ok )
711 return FALSE;
712
713 if ( !m_keyLocal.DeleteValue(oldName) )
714 {
715 m_keyLocal.DeleteValue(newName);
716
717 return FALSE;
718 }
719
720 return TRUE;
721 }
722
723 bool wxRegConfig::RenameGroup(const wxString& oldName, const wxString& newName)
724 {
725 // check that the old group exists...
726 if ( !HasGroup(oldName) )
727 return FALSE;
728
729 // and that the new one doesn't
730 if ( HasGroup(newName) )
731 return FALSE;
732
733 // TODO there is no way to rename a registry key - we must do a deep copy
734 // ourselves
735 wxFAIL_MSG(wxT("Registry key renaming not implemented"));
736
737 return FALSE;
738 }
739
740 // ----------------------------------------------------------------------------
741 // deleting
742 // ----------------------------------------------------------------------------
743 bool wxRegConfig::DeleteEntry(const wxString& value, bool bGroupIfEmptyAlso)
744 {
745 wxConfigPathChanger path(this, value);
746
747 if ( m_keyLocal.Exists() ) {
748 if ( !m_keyLocal.DeleteValue(path.Name()) )
749 return FALSE;
750
751 if ( m_keyLocal.IsEmpty() ) {
752 wxString strKey = GetPath().AfterLast(wxCONFIG_PATH_SEPARATOR);
753 SetPath(".."); // changes m_keyLocal
754 return LocalKey().DeleteKey(strKey);
755 }
756 }
757
758 return TRUE;
759 }
760
761 bool wxRegConfig::DeleteGroup(const wxString& key)
762 {
763 wxConfigPathChanger path(this, key);
764
765 return m_keyLocal.Exists() ? LocalKey().DeleteKey(path.Name()) : TRUE;
766 }
767
768 bool wxRegConfig::DeleteAll()
769 {
770 m_keyLocal.Close();
771 m_keyGlobal.Close();
772
773 bool bOk = m_keyLocalRoot.DeleteSelf();
774
775 // make sure that we opened m_keyGlobalRoot and so it has a reasonable name:
776 // otherwise we will delete HKEY_CLASSES_ROOT recursively
777 if ( bOk && m_keyGlobalRoot.IsOpened() )
778 bOk = m_keyGlobalRoot.DeleteSelf();
779
780 return bOk;
781 }
782
783 #endif
784 // __WIN16__
785
786 #endif
787 // wxUSE_CONFIG