Esempio n. 1
0
bool wxRegKey::CopyValue(const wxString& szValue,
                         wxRegKey& keyDst,
                         const wxString& szValueNew)
{
    wxString valueNew(szValueNew);
    if ( valueNew.empty() ) {
        // by default, use the same name
        valueNew = szValue;
    }

    switch ( GetValueType(szValue) ) {
        case Type_String:
            {
                wxString strVal;
                return QueryValue(szValue, strVal) &&
                       keyDst.SetValue(valueNew, strVal);
            }

        case Type_Dword:
        /* case Type_Dword_little_endian: == Type_Dword */
            {
                long dwVal;
                return QueryValue(szValue, &dwVal) &&
                       keyDst.SetValue(valueNew, dwVal);
            }

        case Type_Binary:
        {
            wxMemoryBuffer buf;
            return QueryValue(szValue,buf) &&
                   keyDst.SetValue(valueNew,buf);
        }

        // these types are unsupported because I am not sure about how
        // exactly they should be copied and because they shouldn't
        // occur among the application keys (supposedly created with
        // this class)
        case Type_None:
        case Type_Expand_String:
        case Type_Dword_big_endian:
        case Type_Link:
        case Type_Multi_String:
        case Type_Resource_list:
        case Type_Full_resource_descriptor:
        case Type_Resource_requirements_list:
        default:
            wxLogError(_("Can't copy values of unsupported type %d."),
                       GetValueType(szValue));
            return false;
    }
}
Esempio n. 2
0
static bool QueryValue(const wxRegKey& rk, const wxString& key, wxString& val)
{
    // prevent pop-up message if key does not exist
    bool save = wxLog::EnableLogging(false);
    bool ok = rk.QueryValue(key, val, false);
    wxLog::EnableLogging(save);
    return ok;
}
Esempio n. 3
0
bool
Verb::ReadFromRegistry(const wxRegKey & base, const wxString & verbName)
{
  // Store descriptive verb name
  m_name = verbName;

  if (!base.HasSubKey(verbName))
    return false;

  wxRegKey verbKey(base, verbName);

  // Read command key
  const wxString commandKeyName(wxT("command"));
  if (!verbKey.HasSubKey(commandKeyName))
    return false;

  wxRegKey commandKey(base, commandKeyName);

  if (commandKey.HasValue(NULL))
    commandKey.QueryValue(NULL, m_command);

  // Attempt to read ddeexec key
  m_ddeCommand.Clear();
  m_ddeTopic.Clear();
  m_ddeApplication.Clear();

  const wxString ddeCommandKeyName(wxT("ddeexec"));
  m_usesDde = verbKey.HasSubKey(ddeCommandKeyName);
  if (m_usesDde)
  {
    wxRegKey ddeCommandKey(verbKey, ddeCommandKeyName);;
    if (ddeCommandKey.HasValue(NULL))
      ddeCommandKey.QueryValue(NULL, m_ddeCommand);

    const wxString ddeTopicName(wxT("Topic"));
    if (ddeCommandKey.HasSubKey(ddeTopicName))
    {
      wxRegKey ddeTopicKey(ddeCommandKey, ddeTopicName);
      if (ddeTopicKey.HasValue(NULL))
        ddeTopicKey.QueryValue(NULL, m_ddeTopic);
    }

    const wxString ddeApplicationName(wxT("Application"));
    if (ddeCommandKey.HasSubKey(ddeApplicationName))
    {
      wxRegKey ddeApplicationKey(ddeCommandKey, ddeApplicationName);
      if (ddeApplicationKey.HasValue(NULL))
        ddeApplicationKey.QueryValue(NULL, m_ddeApplication);
    }
  }

  return true;
}
Esempio n. 4
0
// parent is a normal regkey
wxRegKey::wxRegKey(const wxRegKey& keyParent, const wxString& strKey)
    : m_strKey(keyParent.m_strKey), m_viewMode(keyParent.GetView())
{
  // combine our name with parent's to get the full name
  if ( !m_strKey.empty() &&
       (strKey.empty() || strKey[0] != REG_SEPARATOR) ) {
      m_strKey += REG_SEPARATOR;
  }

  m_strKey += strKey;
  RemoveTrailingSeparator(m_strKey);

  m_hRootKey  = keyParent.m_hRootKey;

  Init();
}
Esempio n. 5
0
bool TryGetValue(const wxRegKey& key, const wxString& str, wxMemoryBuffer &plVal)
{
  return key.IsOpened() && key.HasValue(str) && key.QueryValue(str, plVal);
}
Esempio n. 6
0
bool TryGetValue(const wxRegKey& key, const wxString& str, long *plVal)
{
  return key.IsOpened() && key.HasValue(str) && key.QueryValue(str, plVal);
}