X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f2b039111621a32fcdc9bee440d1ed42325e99c9..8801e78f99ba47fa0201a729b4a9717d603c8250:/src/msw/regconf.cpp?ds=sidebyside diff --git a/src/msw/regconf.cpp b/src/msw/regconf.cpp index c14d3e550c..4bc56da8b6 100644 --- a/src/msw/regconf.cpp +++ b/src/msw/regconf.cpp @@ -24,9 +24,13 @@ #include #endif //WX_PRECOMP +#include #include #include #include + +#ifndef __WIN16__ + #include #include @@ -35,7 +39,7 @@ // ---------------------------------------------------------------------------- // we put our data in HKLM\SOFTWARE_KEY\appname -#define SOFTWARE_KEY wxString("Software\\wxWindows\\") +#define SOFTWARE_KEY wxString("Software\\") // ---------------------------------------------------------------------------- // global functions @@ -433,6 +437,67 @@ bool wxRegConfig::Write(const wxString& key, long lValue) return m_keyLocal.SetValue(path.Name(), lValue); } +// ---------------------------------------------------------------------------- +// renaming +// ---------------------------------------------------------------------------- + +bool wxRegConfig::RenameEntry(const wxString& oldName, const wxString& newName) +{ + // check that the old entry exists... + if ( !HasEntry(oldName) ) + return FALSE; + + // and that the new one doesn't + if ( HasEntry(newName) ) + return FALSE; + + // delete the old entry and create the new one - but do in the reverse + // order to not lose the data if Create() fails + + bool ok; + if ( m_keyLocal.IsNumericValue(oldName) ) + { + long val; + ok = m_keyLocal.QueryValue(oldName, &val) && + m_keyLocal.SetValue(newName, val); + } + else + { + wxString val; + ok = m_keyLocal.QueryValue(oldName, val) && + m_keyLocal.SetValue(newName, val); + } + + if ( !ok ) + return FALSE; + + if ( !m_keyLocal.DeleteValue(oldName) ) + { + m_keyLocal.DeleteValue(newName); + + return FALSE; + } + + return TRUE; +} + +bool wxRegConfig::RenameGroup(const wxString& oldName, const wxString& newName) +{ + // check that the old group exists... + if ( !HasGroup(oldName) ) + return FALSE; + + // and that the new one doesn't + if ( HasGroup(newName) ) + return FALSE; + + // TODO there is no way to rename a registry key - we must do a deep copy + // ourselves + wxFAIL_MSG("Registry key renaming not implemented"); + + return FALSE; +} + // ---------------------------------------------------------------------------- // deleting // ---------------------------------------------------------------------------- @@ -444,7 +509,7 @@ bool wxRegConfig::DeleteEntry(const wxString& value, bool bGroupIfEmptyAlso) return FALSE; if ( !m_keyLocal.HasSubkeys() ) { - wxString strKey = GetPath().Right(wxCONFIG_PATH_SEPARATOR); + wxString strKey = GetPath().AfterLast(wxCONFIG_PATH_SEPARATOR); SetPath(".."); // changes m_keyLocal return m_keyLocal.DeleteKey(strKey); } @@ -463,10 +528,18 @@ bool wxRegConfig::DeleteAll() { m_keyLocal.Close(); m_keyGlobal.Close(); - +#if 1 + wxFAIL_MSG("wxRegConfig::DeleteAll will wipe out your entire registry, so please do not use until it's fixed!"); + return FALSE; +#else bool bOk = m_keyLocalRoot.DeleteSelf(); if ( bOk ) bOk = m_keyGlobalRoot.DeleteSelf(); return bOk; +#endif } + +#endif + // __WIN16__ +