open more keys in read only mode if we need to only read from them (fixes problems with accessing some registry values under XP)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27730 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2004-06-10 16:51:59 +00:00
parent fbbc1982a3
commit d305f9dfff

View File

@ -722,7 +722,7 @@ bool wxRegKey::HasValue(const wxChar *szValue) const
// this function should be silent, so suppress possible messages from Open() // this function should be silent, so suppress possible messages from Open()
wxLogNull nolog; wxLogNull nolog;
if ( !CONST_CAST Open() ) if ( !CONST_CAST Open(Read) )
return FALSE; return FALSE;
LONG dwRet = ::RegQueryValueEx((HKEY) m_hKey, LONG dwRet = ::RegQueryValueEx((HKEY) m_hKey,
@ -762,7 +762,7 @@ bool wxRegKey::HasSubKey(const wxChar *szKey) const
// this function should be silent, so suppress possible messages from Open() // this function should be silent, so suppress possible messages from Open()
wxLogNull nolog; wxLogNull nolog;
if ( !CONST_CAST Open() ) if ( !CONST_CAST Open(Read) )
return FALSE; return FALSE;
return KeyExists(m_hKey, szKey); return KeyExists(m_hKey, szKey);
@ -770,7 +770,7 @@ bool wxRegKey::HasSubKey(const wxChar *szKey) const
wxRegKey::ValueType wxRegKey::GetValueType(const wxChar *szValue) const wxRegKey::ValueType wxRegKey::GetValueType(const wxChar *szValue) const
{ {
if ( ! CONST_CAST Open() ) if ( ! CONST_CAST Open(Read) )
return Type_None; return Type_None;
DWORD dwType; DWORD dwType;
@ -802,7 +802,7 @@ bool wxRegKey::SetValue(const wxChar *szValue, long lValue)
bool wxRegKey::QueryValue(const wxChar *szValue, long *plValue) const bool wxRegKey::QueryValue(const wxChar *szValue, long *plValue) const
{ {
if ( CONST_CAST Open() ) { if ( CONST_CAST Open(Read) ) {
DWORD dwType, dwSize = sizeof(DWORD); DWORD dwType, dwSize = sizeof(DWORD);
RegString pBuf = (RegString)plValue; RegString pBuf = (RegString)plValue;
m_dwLastError = RegQueryValueEx((HKEY) m_hKey, WXSTRINGCAST szValue, RESERVED, m_dwLastError = RegQueryValueEx((HKEY) m_hKey, WXSTRINGCAST szValue, RESERVED,
@ -830,7 +830,7 @@ bool wxRegKey::QueryValue(const wxChar *szValue,
wxString& strValue, wxString& strValue,
bool raw) const bool raw) const
{ {
if ( CONST_CAST Open() ) { if ( CONST_CAST Open(Read) ) {
// first get the type and size of the data // first get the type and size of the data
DWORD dwType, dwSize; DWORD dwType, dwSize;
@ -922,7 +922,7 @@ wxString wxRegKey::QueryDefaultValue() const
bool wxRegKey::GetFirstValue(wxString& strValueName, long& lIndex) bool wxRegKey::GetFirstValue(wxString& strValueName, long& lIndex)
{ {
if ( !Open() ) if ( !Open(Read) )
return FALSE; return FALSE;
lIndex = 0; lIndex = 0;
@ -967,7 +967,7 @@ bool wxRegKey::GetNextValue(wxString& strValueName, long& lIndex) const
bool wxRegKey::GetFirstKey(wxString& strKeyName, long& lIndex) bool wxRegKey::GetFirstKey(wxString& strKeyName, long& lIndex)
{ {
if ( !Open() ) if ( !Open(Read) )
return FALSE; return FALSE;
lIndex = 0; lIndex = 0;