fixed problem with non-const methods not working on wxRegKey initially opened in read-only mode

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34155 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2005-05-18 23:29:54 +00:00
parent a17c1df428
commit fb5e0dcf0d
2 changed files with 10 additions and 1 deletions

View File

@ -245,6 +245,7 @@ private:
m_hRootKey; // handle of the top key (i.e. StdKey)
wxString m_strKey; // key name (relative to m_hRootKey)
AccessMode m_mode; // valid only if key is opened
long m_dwLastError; // last error (0 if none)

View File

@ -364,7 +364,13 @@ bool wxRegKey::GetKeyInfo(size_t *pnSubKeys,
bool wxRegKey::Open(AccessMode mode)
{
if ( IsOpened() )
return true;
{
if ( mode <= m_mode )
return true;
// we had been opened in read mode but now must be reopened in write
Close();
}
HKEY tmpKey;
m_dwLastError = ::RegOpenKeyEx
@ -384,6 +390,8 @@ bool wxRegKey::Open(AccessMode mode)
}
m_hKey = (WXHKEY) tmpKey;
m_mode = mode;
return true;
}