コード例 #1
0
ファイル: qsettings_win.cpp プロジェクト: 13W/phantomjs
QWinSettingsPrivate::QWinSettingsPrivate(QSettings::Scope scope, const QString &organization,
                                         const QString &application)
    : QSettingsPrivate(QSettings::NativeFormat, scope, organization, application)
{
    deleteWriteHandleOnExit = false;

    if (!organization.isEmpty()) {
        QString prefix = QLatin1String("Software\\") + organization;
        QString orgPrefix = prefix + QLatin1String("\\OrganizationDefaults");
        QString appPrefix = prefix + QLatin1Char('\\') + application;

        if (scope == QSettings::UserScope) {
            if (!application.isEmpty())
                regList.append(RegistryKey(HKEY_CURRENT_USER, appPrefix, !regList.isEmpty()));

            regList.append(RegistryKey(HKEY_CURRENT_USER, orgPrefix, !regList.isEmpty()));
        }

        if (!application.isEmpty())
            regList.append(RegistryKey(HKEY_LOCAL_MACHINE, appPrefix, !regList.isEmpty()));

        regList.append(RegistryKey(HKEY_LOCAL_MACHINE, orgPrefix, !regList.isEmpty()));
    }

    if (regList.isEmpty())
        setStatus(QSettings::AccessError);
}
コード例 #2
0
ファイル: qsettings_win.cpp プロジェクト: 13W/phantomjs
QWinSettingsPrivate::QWinSettingsPrivate(QString rPath)
    : QSettingsPrivate(QSettings::NativeFormat)
{
    deleteWriteHandleOnExit = false;

    if (rPath.startsWith(QLatin1String("\\")))
        rPath = rPath.mid(1);

    if (rPath.startsWith(QLatin1String("HKEY_CURRENT_USER\\")))
        regList.append(RegistryKey(HKEY_CURRENT_USER, rPath.mid(18), false));
    else if (rPath == QLatin1String("HKEY_CURRENT_USER"))
        regList.append(RegistryKey(HKEY_CURRENT_USER, QString(), false));
    else if (rPath.startsWith(QLatin1String("HKEY_LOCAL_MACHINE\\")))
        regList.append(RegistryKey(HKEY_LOCAL_MACHINE, rPath.mid(19), false));
    else if (rPath == QLatin1String("HKEY_LOCAL_MACHINE"))
        regList.append(RegistryKey(HKEY_LOCAL_MACHINE, QString(), false));
    else if (rPath.startsWith(QLatin1String("HKEY_CLASSES_ROOT\\")))
        regList.append(RegistryKey(HKEY_CLASSES_ROOT, rPath.mid(18), false));
    else if (rPath == QLatin1String("HKEY_CLASSES_ROOT"))
        regList.append(RegistryKey(HKEY_CLASSES_ROOT, QString(), false));
    else if (rPath.startsWith(QLatin1String("HKEY_USERS\\")))
        regList.append(RegistryKey(HKEY_USERS, rPath.mid(11), false));
    else if (rPath == QLatin1String(QLatin1String("HKEY_USERS")))
        regList.append(RegistryKey(HKEY_USERS, QString(), false));
    else
        regList.append(RegistryKey(HKEY_LOCAL_MACHINE, rPath, false));
}
コード例 #3
0
ファイル: registry_key.cpp プロジェクト: Cassie90/ClanLib
RegistryKey RegistryKey::open_key(const std::string &subkey, unsigned int access_rights)
{
	HKEY new_key = 0;
	LONG result = RegOpenKeyEx(impl->key, StringHelp::utf8_to_ucs2(subkey).c_str(), 0, access_rights, &new_key);
	if (result != ERROR_SUCCESS)
		throw Exception(string_format("Unable to open registry key %1", subkey));
	return RegistryKey(new_key);
}
コード例 #4
0
QWinSettingsPrivate::QWinSettingsPrivate(QString rPath)
    : QSettingsPrivate(QSettings::NativeFormat)
{
    deleteWriteHandleOnExit = false;

    if (rPath.startsWith(QLatin1Char('\\')))
        rPath.remove(0, 1);

    int keyLength;
    HKEY keyName;

    if (rPath.startsWith(QLatin1String("HKEY_CURRENT_USER"))) {
        keyLength = 17;
        keyName = HKEY_CURRENT_USER;
    } else if (rPath.startsWith(QLatin1String("HKCU"))) {
        keyLength = 4;
        keyName = HKEY_CURRENT_USER;
    } else if (rPath.startsWith(QLatin1String("HKEY_LOCAL_MACHINE"))) {
        keyLength = 18;
        keyName = HKEY_LOCAL_MACHINE;
    } else if (rPath.startsWith(QLatin1String("HKLM"))) {
        keyLength = 4;
        keyName = HKEY_LOCAL_MACHINE;
    } else if (rPath.startsWith(QLatin1String("HKEY_CLASSES_ROOT"))) {
        keyLength = 17;
        keyName = HKEY_CLASSES_ROOT;
    } else if (rPath.startsWith(QLatin1String("HKCR"))) {
        keyLength = 4;
        keyName = HKEY_CLASSES_ROOT;
    } else if (rPath.startsWith(QLatin1String("HKEY_USERS"))) {
        keyLength = 10;
        keyName = HKEY_USERS;
    } else if (rPath.startsWith(QLatin1String("HKU"))) {
        keyLength = 3;
        keyName = HKEY_USERS;
    } else {
        return;
    }

    if (rPath.length() == keyLength)
        regList.append(RegistryKey(keyName, QString(), false));
    else if (rPath[keyLength] == QLatin1Char('\\'))
        regList.append(RegistryKey(keyName, rPath.mid(keyLength+1), false));
}
コード例 #5
0
ファイル: com-module.cpp プロジェクト: sirmax1/coin
void CComGeneralClass::Register() {
#if UCFG_EXTENDED
	String moduleName = AfxGetModuleState()->FileName;
	String sClsid = StringFromCLSID(m_clsid);
	String sDesc;
	sDesc.Load(m_descID);
	if (!m_progID.IsEmpty()) {
		RegistryKey key(HKEY_CLASSES_ROOT, m_progID);
		key.SetValue("", sDesc);
		RegistryKey ck(key, "CLSID");
		ck.SetValue("", sClsid);
	}
	if (m_progID != m_indProgID) {
		RegistryKey key(HKEY_CLASSES_ROOT, m_indProgID);
		key.SetValue("", sDesc);
		RegistryKey ck(key, "CLSID");
		ck.SetValue("", sClsid);
	}
	RegistryKey key(HKEY_CLASSES_ROOT, "CLSID\\"+sClsid);
	key.SetValue("", sDesc);
	RegistryKey(key, "ProgID").SetValue("", m_progID);
	if (m_progID != m_indProgID)
		RegistryKey(key, "VersionIndependentProgID").SetValue("", m_indProgID);
	if (AfxGetModuleState()->m_hCurrentInstanceHandle == GetModuleHandle(0)) {
		RegistryKey lsk(key, "LocalServer32");
		lsk.SetValue("", moduleName);
	} else {
		RegistryKey isk(key, "InprocServer32");
		isk.SetValue("", moduleName);
		String tm;
		if (m_flags & THREADFLAGS_BOTH)
			tm = "both";
		else if (m_flags & THREADFLAGS_APARTMENT)
			tm = "Apartment";
		if (!tm.IsEmpty())
			isk.SetValue("ThreadingModel", tm);
	}
#endif
}
コード例 #6
0
ファイル: registry_key.cpp プロジェクト: Cassie90/ClanLib
RegistryKey RegistryKey::create_key(const std::string &subkey, unsigned int access_rights, CreateFlags create_flags)
{
	DWORD disposition = 0;
	HKEY new_key = 0;
	LONG result = RegCreateKeyEx(impl->key, StringHelp::utf8_to_ucs2(subkey).c_str(), 0, 0, (create_flags & create_volatile) ? REG_OPTION_VOLATILE : REG_OPTION_NON_VOLATILE, access_rights, 0, &new_key, &disposition);
	if (result != ERROR_SUCCESS)
		throw Exception(string_format("Unable to create registry key %1", subkey));

	if (disposition != REG_CREATED_NEW_KEY && (create_flags & create_new))
	{
		RegCloseKey(new_key);
		throw Exception(string_format("Key already exists: %1", subkey));
	}

	return RegistryKey(new_key);
}
コード例 #7
0
ファイル: proto-eng.cpp プロジェクト: ufasoft/snif
void CProtoEngBase::LoadFilter() {
#if UCFG_EXTENDED
	try {
		SetUserFilter(RegistryKey(AfxGetCApp()->KeyCU, "Filter").TryQueryValue("TcpdumpString", ""));
	} catch (RCExc) {
		cerr << "Invalid User Filter" << endl;
	}

#	if UCFG_SNIF_WIFI
	try {
		SetWifiKeys(AfxGetCApp()->KeyCU.TryQueryValue("WepKeys", vector<String>()));
	} catch (RCExc e) {
		cerr << e << endl;
	}
#	endif
#endif
}
コード例 #8
0
RegistryKey InitializeParameters::getKey() { // static
  return RegistryKey(HKEY_CURRENT_USER,_T("Software")).createOrOpenKey(_T("JGMData\\SortDemo\\Settings"));
}
コード例 #9
0
ファイル: Enumerator.cpp プロジェクト: DRIZO/xcsoar
bool
PortEnumerator::Next()
{
  assert(!drivers_active.error());

  TCHAR key_name[64];

  /* enumerate regular serial ports first */

  while (drivers_active.EnumKey(i++, key_name, 64)) {
    RegistryKey device(drivers_active, key_name, true);
    if (device.error())
      continue;

    TCHAR device_key[64];
    if (device.GetValue(_T("Key"), device_key, 64) &&
        IsSerialPort(device_key) &&
        device.GetValue(_T("Name"), name.buffer(), name.MAX_SIZE)) {
      display_name = name;
      const size_t length = display_name.length();
      TCHAR *const tail = display_name.buffer() + length;
      const size_t remaining = display_name.MAX_SIZE - length - 3;

      if (GetDeviceFriendlyName(device_key, tail + 2, remaining)) {
        /* build a string in the form: "COM1: (Friendly Name)" */
        tail[0] = _T(' ');
        tail[1] = _T('(');
        _tcscat(tail, _T(")"));
      }

      return true;
    }
  }

  /* virtual Bluetooth serial ports will not be found by the above;
     the following is necessary to enumerate those */

  while (bluetooth_ports.EnumKey(j++, key_name, 64)) {
    RegistryKey port(bluetooth_ports, key_name, true);
    if (port.error())
      continue;

    if (!port.GetValue(_T("Port"), name.buffer(), name.MAX_SIZE - 1))
      continue;

    /* the trailing colon is missing in this part of the registry */
    name.Append(_T(':'));

    display_name = name;

    /* see if we can find a human-readable name */
    const TCHAR *kn = key_name;
    RegistryKey device(bluetooth_device, kn, true);
    while (device.error() && *kn == _T('0')) {
      /* turns out Windows CE strips four leading zeroes for the
         Bluetooth\Device\* key (12 digits instead of 16); this is an
         attempt to kludge around this weirdness */
      ++kn;
      device = RegistryKey(bluetooth_device, kn, true);
    }

    if (!device.error()) {
      const size_t length = display_name.length();
      TCHAR *const tail = display_name.buffer() + length;
      const size_t remaining = display_name.MAX_SIZE - length - 3;

      if (device.GetValue(_T("name"), tail + 2, remaining)) {
        /* build a string in the form: "COM1: (Friendly Name)" */
        tail[0] = _T(' ');
        tail[1] = _T('(');
        _tcscat(tail, _T(")"));
      }
    }

    return true;
  }

  return false;
}
コード例 #10
0
RegistryKey Options::getKey() { // static
  return RegistryKey(HKEY_CURRENT_USER,registryEntry).createOrOpenKey(_T("Settings"));
}