]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/registry.cpp
Add wxGrid::Render() for drawing the grid to any wxDC.
[wxWidgets.git] / src / msw / registry.cpp
index 0825e131fc1247967ac2f67e97b95cfb00478800..80903a6e4d473375c01d9edc10d3c1a17ba13f41 100644 (file)
@@ -68,6 +68,10 @@ typedef BYTE* RegBinary;
     #define HKEY_DYN_DATA ((HKEY)0x80000006)
 #endif
 
+#ifndef KEY_WOW64_64KEY
+    #define KEY_WOW64_64KEY 0x0100
+#endif
+
 // ----------------------------------------------------------------------------
 // constants
 // ----------------------------------------------------------------------------
@@ -322,7 +326,7 @@ void wxRegKey::SetHkey(WXHKEY hKey)
   m_mode = Write;
 
   // reset old data
-  m_strKey.empty();
+  m_strKey.clear();
   m_dwLastError = 0;
 }
 
@@ -356,36 +360,57 @@ bool wxRegKey::GetKeyInfo(size_t *pnSubKeys,
                           size_t *pnValues,
                           size_t *pnMaxValueLen) const
 {
-    // old gcc headers incorrectly prototype RegQueryInfoKey()
-#if defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__)
-    #define REG_PARAM   (size_t *)
-#else
-    #define REG_PARAM   (LPDWORD)
-#endif
-
   // it might be unexpected to some that this function doesn't open the key
   wxASSERT_MSG( IsOpened(), wxT("key should be opened in GetKeyInfo") );
 
+  // We need to use intermediate variables in 64 bit build as the function
+  // parameters must be 32 bit DWORDs and not 64 bit size_t values.
+#ifdef __WIN64__
+  DWORD dwSubKeys = 0,
+        dwMaxKeyLen = 0,
+        dwValues = 0,
+        dwMaxValueLen = 0;
+
+  #define REG_PARAM(name) &dw##name
+#else // Win32
+  // Old gcc headers incorrectly prototype RegQueryInfoKey() as taking
+  // size_t but normally we need a cast, even when sizeof(size_t) is the same
+  // as sizeof(DWORD).
+  #if defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__)
+    #define REG_PARAM(name) pn##name
+  #else
+    #define REG_PARAM(name)   (LPDWORD)(pn##name)
+  #endif
+#endif
+
+
   m_dwLastError = ::RegQueryInfoKey
                   (
                     (HKEY) m_hKey,
-                    NULL,           // class name
-                    NULL,           // (ptr to) size of class name buffer
+                    NULL,                   // class name
+                    NULL,                   // (ptr to) size of class name buffer
                     RESERVED,
-                    REG_PARAM
-                    pnSubKeys,      // [out] number of subkeys
-                    REG_PARAM
-                    pnMaxKeyLen,    // [out] max length of a subkey name
-                    NULL,           // longest subkey class name
-                    REG_PARAM
-                    pnValues,       // [out] number of values
-                    REG_PARAM
-                    pnMaxValueLen,  // [out] max length of a value name
-                    NULL,           // longest value data
-                    NULL,           // security descriptor
-                    NULL            // time of last modification
+                    REG_PARAM(SubKeys),     // [out] number of subkeys
+                    REG_PARAM(MaxKeyLen),   // [out] max length of a subkey name
+                    NULL,                   // longest subkey class name
+                    REG_PARAM(Values),      // [out] number of values
+                    REG_PARAM(MaxValueLen), // [out] max length of a value name
+                    NULL,                   // longest value data
+                    NULL,                   // security descriptor
+                    NULL                    // time of last modification
                   );
 
+#ifdef __WIN64__
+  if ( pnSubKeys )
+    *pnSubKeys = dwSubKeys;
+  if ( pnMaxKeyLen )
+    *pnMaxKeyLen = dwMaxKeyLen;
+  if ( pnValues )
+    *pnValues = dwValues;
+  if ( pnMaxValueLen )
+    *pnMaxValueLen = dwMaxValueLen;
+#endif // __WIN64__
+
 #undef REG_PARAM
 
   if ( m_dwLastError != ERROR_SUCCESS ) {
@@ -1032,7 +1057,7 @@ bool wxRegKey::SetValue(const wxString& szValue, const wxString& strValue)
       m_dwLastError = RegSetValueEx((HKEY) m_hKey,
                                     RegValueStr(szValue),
                                     (DWORD) RESERVED, REG_SZ,
-                                    (RegString)strValue.t_str(),
+                                    (RegString)static_cast<const TCHAR *>(strValue.t_str()),
                                     (strValue.Len() + 1)*sizeof(wxChar));
       if ( m_dwLastError == ERROR_SUCCESS )
         return true;
@@ -1210,7 +1235,7 @@ bool wxRegKey::Export(const wxString& filename) const
 
     wxFFileOutputStream ostr(filename, wxT("w"));
 
-    return ostr.Ok() && Export(ostr);
+    return ostr.IsOk() && Export(ostr);
 #else
     wxUnusedVar(filename);
     return false;