From fb5e0dcf0d1f1f82cda094f3cb6099662dcad9be Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 18 May 2005 23:29:54 +0000 Subject: [PATCH] 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 --- include/wx/msw/registry.h | 1 + src/msw/registry.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/wx/msw/registry.h b/include/wx/msw/registry.h index ec2fe0a842..5f9020a7e7 100644 --- a/include/wx/msw/registry.h +++ b/include/wx/msw/registry.h @@ -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) diff --git a/src/msw/registry.cpp b/src/msw/registry.cpp index 70dd768c12..3cf956f7d2 100644 --- a/src/msw/registry.cpp +++ b/src/msw/registry.cpp @@ -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; } -- 2.45.2