]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/registry.cpp
placeholder
[wxWidgets.git] / src / msw / registry.cpp
index 9462ef29f0ed6452b45dd8ce2b467c5671d66009..72515030b03c476f2f708a74b1183a5aa8a6c992 100644 (file)
@@ -12,7 +12,7 @@
 //              - add high level functions (RegisterOleServer, ...)
 ///////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
 #pragma implementation "registry.h"
 #endif
 
@@ -374,7 +374,7 @@ bool wxRegKey::GetKeyInfo(size_t *pnSubKeys,
 // ----------------------------------------------------------------------------
 
 // opens key (it's not an error to call Open() on an already opened key)
-bool wxRegKey::Open()
+bool wxRegKey::Open(AccessMode mode)
 {
     if ( IsOpened() )
         return TRUE;
@@ -385,7 +385,7 @@ bool wxRegKey::Open()
                         (HKEY) m_hRootKey,
                         m_strKey,
                         RESERVED,
-                        KEY_ALL_ACCESS,
+                        mode == Read ? KEY_READ : KEY_ALL_ACCESS,
                         &tmpKey
                     );
 
@@ -683,7 +683,9 @@ bool wxRegKey::DeleteSelf()
   Close();
 
   m_dwLastError = RegDeleteKey((HKEY) m_hRootKey, m_strKey);
-  if ( m_dwLastError != ERROR_SUCCESS ) {
+  // deleting a key which doesn't exist is not considered an error
+  if ( m_dwLastError != ERROR_SUCCESS &&
+          m_dwLastError != ERROR_FILE_NOT_FOUND ) {
     wxLogSysError(m_dwLastError, _("Can't delete key '%s'"),
                   GetName().c_str());
     return FALSE;
@@ -872,14 +874,12 @@ bool wxRegKey::QueryValue(const wxChar *szValue,
             strValue.Empty();
         }
         else {
-            RegString pBuf = (RegString)strValue.GetWriteBuf(dwSize);
             m_dwLastError = RegQueryValueEx((HKEY) m_hKey,
                                             WXSTRINGCAST szValue,
                                             RESERVED,
                                             &dwType,
-                                            pBuf,
+                                            (RegString)(wxChar*)wxStringBuffer(strValue, dwSize),
                                             &dwSize);
-            strValue.UngetWriteBuf();
 
             // expand the var expansions in the string unless disabled
 #ifndef __WXWINCE__
@@ -893,10 +893,9 @@ bool wxRegKey::QueryValue(const wxChar *szValue,
                     ok = ::ExpandEnvironmentStrings
                            (
                             strValue,
-                            strExpValue.GetWriteBuf(dwExpSize),
+                            wxStringBuffer(strExpValue, dwExpSize),
                             dwExpSize
                            ) != 0;
-                    strExpValue.UngetWriteBuf();
                     strValue = strExpValue;
                 }
 
@@ -1098,7 +1097,7 @@ bool KeyExists(WXHKEY hRootKey, const wxChar *szKey)
             (HKEY)hRootKey,
             szKey,
             RESERVED,
-            KEY_ALL_ACCESS,
+            KEY_READ,        // we might not have enough rights for rw access
             &hkeyDummy
          ) == ERROR_SUCCESS )
     {