// removes the trailing backslash from the string if it has one
static inline void RemoveTrailingSeparator(wxString& str);
// removes the trailing backslash from the string if it has one
static inline void RemoveTrailingSeparator(wxString& str);
static bool KeyExists(HKEY hRootKey, const char *szKey);
// combines value and key name (uses static buffer!)
static bool KeyExists(HKEY hRootKey, const char *szKey);
// combines value and key name (uses static buffer!)
bool wxRegKey::Exists() const
{
// opened key has to exist, try to open it if not done yet
bool wxRegKey::Exists() const
{
// opened key has to exist, try to open it if not done yet
m_dwLastError = RegOpenKey(m_hRootKey, m_strKey, &m_hKey);
if ( m_dwLastError != ERROR_SUCCESS ) {
wxLogSysError(m_dwLastError, "can't open registry key '%s'",
GetName().c_str());
m_dwLastError = RegOpenKey(m_hRootKey, m_strKey, &m_hKey);
if ( m_dwLastError != ERROR_SUCCESS ) {
wxLogSysError(m_dwLastError, "can't open registry key '%s'",
GetName().c_str());
m_dwLastError = RegCreateKey(m_hRootKey, m_strKey, &m_hKey);
if ( m_dwLastError != ERROR_SUCCESS ) {
wxLogSysError(m_dwLastError, "can't create registry key '%s'",
GetName().c_str());
m_dwLastError = RegCreateKey(m_hRootKey, m_strKey, &m_hKey);
if ( m_dwLastError != ERROR_SUCCESS ) {
wxLogSysError(m_dwLastError, "can't create registry key '%s'",
GetName().c_str());
#ifdef __WIN32__
m_dwLastError = RegDeleteValue(m_hKey, szValue);
if ( m_dwLastError != ERROR_SUCCESS ) {
wxLogSysError(m_dwLastError, "can't delete value '%s' from key '%s'",
szValue, GetName().c_str());
#ifdef __WIN32__
m_dwLastError = RegDeleteValue(m_hKey, szValue);
if ( m_dwLastError != ERROR_SUCCESS ) {
wxLogSysError(m_dwLastError, "can't delete value '%s' from key '%s'",
szValue, GetName().c_str());
if ( m_dwLastError != ERROR_SUCCESS ) {
wxLogSysError(m_dwLastError, "can't delete value of key '%s'",
GetName().c_str());
if ( m_dwLastError != ERROR_SUCCESS ) {
wxLogSysError(m_dwLastError, "can't delete value of key '%s'",
GetName().c_str());
}
// ----------------------------------------------------------------------------
// access to values and subkeys
// ----------------------------------------------------------------------------
}
// ----------------------------------------------------------------------------
// access to values and subkeys
// ----------------------------------------------------------------------------
bool wxRegKey::HasSubKey(const char *szKey) const
{
if ( CONST_CAST Open() )
return KeyExists(m_hKey, szKey);
else
bool wxRegKey::HasSubKey(const char *szKey) const
{
if ( CONST_CAST Open() )
return KeyExists(m_hKey, szKey);
else
m_dwLastError = RegSetValueEx(m_hKey, szValue, RESERVED, REG_DWORD,
(RegString)&lValue, sizeof(lValue));
if ( m_dwLastError == ERROR_SUCCESS )
m_dwLastError = RegSetValueEx(m_hKey, szValue, RESERVED, REG_DWORD,
(RegString)&lValue, sizeof(lValue));
if ( m_dwLastError == ERROR_SUCCESS )
}
wxLogSysError(m_dwLastError, "can't set value of '%s'",
GetFullName(this, szValue));
}
wxLogSysError(m_dwLastError, "can't set value of '%s'",
GetFullName(this, szValue));
if ( m_dwLastError != ERROR_SUCCESS ) {
wxLogSysError(m_dwLastError, "can't read value of key '%s'",
GetName().c_str());
if ( m_dwLastError != ERROR_SUCCESS ) {
wxLogSysError(m_dwLastError, "can't read value of key '%s'",
GetName().c_str());
}
else {
// check that we read the value of right type
wxASSERT_MSG( dwType == REG_DWORD,
"Type mismatch in wxRegKey::QueryValue()." );
}
else {
// check that we read the value of right type
wxASSERT_MSG( dwType == REG_DWORD,
"Type mismatch in wxRegKey::QueryValue()." );
wxASSERT_MSG( dwType == REG_SZ,
"Type mismatch in wxRegKey::QueryValue()." );
wxASSERT_MSG( dwType == REG_SZ,
"Type mismatch in wxRegKey::QueryValue()." );
m_dwLastError = RegQueryValue(m_hKey, 0, strValue.GetWriteBuf(256), &l);
if ( m_dwLastError == ERROR_SUCCESS )
m_dwLastError = RegQueryValue(m_hKey, 0, strValue.GetWriteBuf(256), &l);
if ( m_dwLastError == ERROR_SUCCESS )
#endif //WIN16/32
}
wxLogSysError(m_dwLastError, "can't read value of '%s'",
GetFullName(this, szValue));
#endif //WIN16/32
}
wxLogSysError(m_dwLastError, "can't read value of '%s'",
GetFullName(this, szValue));
(RegString)strValue.c_str(),
strValue.Len() + 1);
if ( m_dwLastError == ERROR_SUCCESS )
(RegString)strValue.c_str(),
strValue.Len() + 1);
if ( m_dwLastError == ERROR_SUCCESS )
#else //WIN16
// named registry values don't exist in Win16
wxASSERT( IsEmpty(szValue) );
m_dwLastError = RegSetValue(m_hKey, NULL, REG_SZ, strValue, NULL);
if ( m_dwLastError == ERROR_SUCCESS )
#else //WIN16
// named registry values don't exist in Win16
wxASSERT( IsEmpty(szValue) );
m_dwLastError = RegSetValue(m_hKey, NULL, REG_SZ, strValue, NULL);
if ( m_dwLastError == ERROR_SUCCESS )
#endif //WIN16/32
}
wxLogSysError(m_dwLastError, "can't set value of '%s'",
GetFullName(this, szValue));
#endif //WIN16/32
}
wxLogSysError(m_dwLastError, "can't set value of '%s'",
GetFullName(this, szValue));
char szKeyName[_MAX_PATH + 1];
m_dwLastError = RegEnumKey(m_hKey, lIndex++, szKeyName, WXSIZEOF(szKeyName));
char szKeyName[_MAX_PATH + 1];
m_dwLastError = RegEnumKey(m_hKey, lIndex++, szKeyName, WXSIZEOF(szKeyName));