]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/registry.cpp
ODBC updates (it almost works now)
[wxWidgets.git] / src / msw / registry.cpp
index 6269c4de4aadf93fd75f68b29dc75a57d7787ca6..bb51ed0337cc0087027fd68a087a029ea709c2e1 100644 (file)
 #pragma implementation "registry.h"
 #endif
 
-// ============================================================================
-// declarations
-// ============================================================================
-
-// ----------------------------------------------------------------------------
-// headers
-// ----------------------------------------------------------------------------
-
 // for compilers that support precompilation, includes "wx.h".
 #include  "wx/wxprec.h"
 
@@ -152,7 +144,7 @@ wxRegKey::StdKey wxRegKey::ExtractKeyName(wxString& strKey)
 {
   wxString strRoot = strKey.Left(REG_SEPARATOR);
 
-  HKEY hRootKey;
+  HKEY hRootKey = 0;
   size_t ui;
   for ( ui = 0; ui < nStdKeys; ui++ ) {
     if ( strRoot.CmpNoCase(aStdKeys[ui].szName) == 0 || 
@@ -202,7 +194,7 @@ wxRegKey::wxRegKey()
 wxRegKey::wxRegKey(const wxString& strKey) : m_strKey(strKey)
 {
   m_hRootKey  = (WXHKEY) aStdKeys[ExtractKeyName(m_strKey)].hkey;
-  m_hKey      = NULL;
+  m_hKey      = (WXHKEY) NULL;
   m_dwLastError = 0;
 }
 
@@ -211,7 +203,7 @@ wxRegKey::wxRegKey(StdKey keyParent, const wxString& strKey) : m_strKey(strKey)
 {
   RemoveTrailingSeparator(m_strKey);
   m_hRootKey  = (WXHKEY) aStdKeys[keyParent].hkey;
-  m_hKey      = NULL;
+  m_hKey      = (WXHKEY) NULL;
   m_dwLastError = 0;
 }
 
@@ -229,7 +221,7 @@ wxRegKey::wxRegKey(const wxRegKey& keyParent, const wxString& strKey)
   RemoveTrailingSeparator(m_strKey);
 
   m_hRootKey  = keyParent.m_hRootKey;
-  m_hKey      = NULL;
+  m_hKey      = (WXHKEY) NULL;
   m_dwLastError = 0;
 }
 
@@ -482,7 +474,7 @@ bool wxRegKey::DeleteValue(const char *szValue)
     return FALSE;
 
   #ifdef  __WIN32__
-    m_dwLastError = RegDeleteValue((HKEY) m_hKey, szValue);
+    m_dwLastError = RegDeleteValue((HKEY) m_hKey, (char*) (const char*) szValue);
     if ( m_dwLastError != ERROR_SUCCESS ) {
       wxLogSysError(m_dwLastError, _("can't delete value '%s' from key '%s'"),
                     szValue, GetName().c_str());
@@ -516,7 +508,7 @@ bool wxRegKey::HasValue(const char *szValue) const
   
   #ifdef  __WIN32__
     if ( CONST_CAST Open() ) {
-      return RegQueryValueEx((HKEY) m_hKey, szValue, RESERVED,
+      return RegQueryValueEx((HKEY) m_hKey, (char*) (const char*) szValue, RESERVED,
                              NULL, NULL, NULL) == ERROR_SUCCESS;
     }
     else
@@ -530,6 +522,9 @@ bool wxRegKey::HasValue(const char *szValue) const
 // returns TRUE if this key has any subkeys
 bool wxRegKey::HasSubkeys() const
 {
+  // suppress possible messages from GetFirstKey()
+  wxLogNull nolog;
+  
   // just call GetFirstKey with dummy parameters
   wxString str;
   long     l;
@@ -539,6 +534,9 @@ bool wxRegKey::HasSubkeys() const
 // returns TRUE if given subkey exists
 bool wxRegKey::HasSubKey(const char *szKey) const
 {
+  // this function should be silent, so suppress possible messages from Open()
+  wxLogNull nolog;
+  
   if ( CONST_CAST Open() )
     return KeyExists(m_hKey, szKey);
   else
@@ -552,7 +550,7 @@ wxRegKey::ValueType wxRegKey::GetValueType(const char *szValue)
       return Type_None;
 
     DWORD dwType;
-    m_dwLastError = RegQueryValueEx((HKEY) m_hKey, szValue, RESERVED,
+    m_dwLastError = RegQueryValueEx((HKEY) m_hKey, (char*) (const char*) szValue, RESERVED,
                                     &dwType, NULL, NULL);
     if ( m_dwLastError != ERROR_SUCCESS ) {
       wxLogSysError(m_dwLastError, _("can't read value of key '%s'"),
@@ -570,7 +568,7 @@ wxRegKey::ValueType wxRegKey::GetValueType(const char *szValue)
 bool wxRegKey::SetValue(const char *szValue, long lValue)
 {
   if ( CONST_CAST Open() ) {
-    m_dwLastError = RegSetValueEx((HKEY) m_hKey, szValue, RESERVED, REG_DWORD,
+    m_dwLastError = RegSetValueEx((HKEY) m_hKey, szValue, (DWORD) RESERVED, REG_DWORD,
                                   (RegString)&lValue, sizeof(lValue));
     if ( m_dwLastError == ERROR_SUCCESS )
       return TRUE;
@@ -586,7 +584,7 @@ bool wxRegKey::QueryValue(const char *szValue, long *plValue) const
   if ( CONST_CAST Open() ) {
     DWORD dwType, dwSize = sizeof(DWORD);
     RegString pBuf = (RegString)plValue;
-    m_dwLastError = RegQueryValueEx((HKEY) m_hKey, szValue, RESERVED,
+    m_dwLastError = RegQueryValueEx((HKEY) m_hKey, (char*) (const char*) szValue, RESERVED,
                                     &dwType, pBuf, &dwSize);
     if ( m_dwLastError != ERROR_SUCCESS ) {
       wxLogSysError(m_dwLastError, _("can't read value of key '%s'"),
@@ -613,11 +611,11 @@ bool wxRegKey::QueryValue(const char *szValue, wxString& strValue) const
     #ifdef  __WIN32__
       // first get the type and size of the data
       DWORD dwType, dwSize;
-      m_dwLastError = RegQueryValueEx((HKEY) m_hKey, szValue, RESERVED,
+      m_dwLastError = RegQueryValueEx((HKEY) m_hKey, (char*) (const char*) szValue, RESERVED,
                                       &dwType, NULL, &dwSize);
       if ( m_dwLastError == ERROR_SUCCESS ) {
         RegString pBuf = (RegString)strValue.GetWriteBuf(dwSize);
-        m_dwLastError = RegQueryValueEx((HKEY) m_hKey, szValue, RESERVED,
+        m_dwLastError = RegQueryValueEx((HKEY) m_hKey, (char*) (const char*) szValue, RESERVED,
                                         &dwType, pBuf, &dwSize);
         strValue.UngetWriteBuf();
         if ( m_dwLastError == ERROR_SUCCESS ) {
@@ -648,7 +646,7 @@ bool wxRegKey::SetValue(const char *szValue, const wxString& strValue)
 {
   if ( CONST_CAST Open() ) {
     #ifdef  __WIN32__
-      m_dwLastError = RegSetValueEx((HKEY) m_hKey, szValue, RESERVED, REG_SZ,
+      m_dwLastError = RegSetValueEx((HKEY) m_hKey, szValue, (DWORD) RESERVED, REG_SZ,
                                     (RegString)strValue.c_str(), 
                                     strValue.Len() + 1);
       if ( m_dwLastError == ERROR_SUCCESS )