// Created: 03.04.98
// RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
-// Licence: wxWindows license
+// Licence: wxWindows licence
// TODO: - parsing of registry key names
// - support of other (than REG_SZ/REG_DWORD) registry types
// - add high level functions (RegisterOleServer, ...)
// returns the full name of the key (prefix is abbreviated if bShortPrefix)
wxString wxRegKey::GetName(bool bShortPrefix) const
{
- StdKey key = GetStdKeyFromHkey((StdKey) m_hRootKey);
+ StdKey key = GetStdKeyFromHkey((WXHKEY) m_hRootKey);
wxString str = bShortPrefix ? aStdKeys[key].szShortName
: aStdKeys[key].szName;
if ( !m_strKey.IsEmpty() )
- str << "\\" << m_strKey;
+ str << _T("\\") << m_strKey;
return str;
}
size_t *pnValues,
size_t *pnMaxValueLen) const
{
-#if defined(__WIN32__) && !defined(__TWIN32__)
+#if defined(__WIN32__)
// old gcc headers incorrectly prototype RegQueryInfoKey()
#if defined(__GNUWIN32_OLD__) && !defined(__CYGWIN10__)
if ( !Open() )
return FALSE;
-#if defined(__WIN32__) && !defined(__TWIN32__)
+#if defined(__WIN32__)
m_dwLastError = RegDeleteValue((HKEY) m_hKey, WXSTRINGCAST szValue);
if ( m_dwLastError != ERROR_SUCCESS ) {
wxLogSysError(m_dwLastError, _("Can't delete value '%s' from key '%s'"),
szValue, GetName().c_str());
return FALSE;
}
- #else //WIN16
+#else //WIN16
// named registry values don't exist in Win16 world
wxASSERT( IsEmpty(szValue) );
GetName().c_str());
return FALSE;
}
- #endif //WIN16/32
+#endif //WIN16/32
return TRUE;
}
#ifdef __WIN32__
bool wxRegKey::SetValue(const wxChar *szValue, long lValue)
{
-#ifdef __TWIN32__
- wxFAIL_MSG("RegSetValueEx not implemented by TWIN32");
- return FALSE;
-#else
if ( CONST_CAST Open() ) {
m_dwLastError = RegSetValueEx((HKEY) m_hKey, szValue, (DWORD) RESERVED, REG_DWORD,
(RegString)&lValue, sizeof(lValue));
wxLogSysError(m_dwLastError, _("Can't set value of '%s'"),
GetFullName(this, szValue));
return FALSE;
-#endif
}
bool wxRegKey::QueryValue(const wxChar *szValue, long *plValue) const
bool wxRegKey::SetValue(const wxChar *szValue, const wxString& strValue)
{
if ( CONST_CAST Open() ) {
-#if defined( __WIN32__) && !defined(__TWIN32__)
+#if defined( __WIN32__)
m_dwLastError = RegSetValueEx((HKEY) m_hKey, szValue, (DWORD) RESERVED, REG_SZ,
(RegString)strValue.c_str(),
(strValue.Len() + 1)*sizeof(wxChar));
if ( m_dwLastError == ERROR_SUCCESS )
return TRUE;
- #else //WIN16
+#else //WIN16
// named registry values don't exist in Win16
wxASSERT( IsEmpty(szValue) );
m_dwLastError = RegSetValue((HKEY) m_hKey, NULL, REG_SZ, strValue, NULL);
if ( m_dwLastError == ERROR_SUCCESS )
return TRUE;
- #endif //WIN16/32
+#endif //WIN16/32
}
wxLogSysError(m_dwLastError, _("Can't set value of '%s'"),
return FALSE;
}
-wxRegKey::operator wxString() const
+wxString wxRegKey::QueryDefaultValue() const
{
wxString str;
QueryValue(NULL, str);
if ( lIndex == -1 )
return FALSE;
-#if defined( __WIN32__) && !defined(__TWIN32__)
+#if defined( __WIN32__)
wxChar szValueName[1024]; // @@ use RegQueryInfoKey...
DWORD dwValueLen = WXSIZEOF(szValueName);
}
strValueName = szValueName;
- #else //WIN16
+#else //WIN16
// only one unnamed value
wxASSERT( lIndex == 0 );
lIndex = -1;
strValueName.Empty();
- #endif
+#endif
return TRUE;
}