当前位置: 首页>>代码示例>>C++>>正文


C++ RegistryKey类代码示例

本文整理汇总了C++中RegistryKey的典型用法代码示例。如果您正苦于以下问题:C++ RegistryKey类的具体用法?C++ RegistryKey怎么用?C++ RegistryKey使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RegistryKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ServiceParamInstall

DWORD ServiceParametersBase::ServiceParamInstall(void)
{
	RegistryKey				regKey;		// Registry key wrapper object
	PSERVICE_PARAMETER_MAP	pParamMap;	// Pointer to a SERVICE_PARAMETER_ENTRY
	DWORD					dwResult;	// Result from function call

	// Attempt to create the service parameters registry key object, and
	// open it with both KEY_READ and KEY_WRITE access

	dwResult = regKey.Create(HKEY_LOCAL_MACHINE, GetParametersKeyName(), 
		KEY_READ | KEY_WRITE);

	if(dwResult != ERROR_SUCCESS) return dwResult;

	pParamMap = GetParameterMap();		// Retrieve the PARAMETER_MAP
	_ASSERTE(pParamMap != NULL);		// Should never be NULL

	// Loop through the PARAMETER_MAP and add any parameters that are not already
	// set up in the registry key.  We don't worry about failure too much in here,
	// since the Parameter class will always provide a default value if need be
	
	while(pParamMap->pEntry) {

		if(pParamMap->pEntry->Load(regKey) != ERROR_SUCCESS) 
			pParamMap->pEntry->Save(regKey);

		pParamMap++;					// Move to the next parameter
	}

	return ERROR_SUCCESS;
}
开发者ID:zukisoft,项目名称:external,代码行数:31,代码来源:svctlreg.cpp

示例2: GetCurrentParamsPath

void GetCurrentParamsPath(TSTRING &tsPath) {

  RegistryKey Key;

  if (!Key.Create(FURR_ROOTREGISTRYKEY, FURR_REGISTRYCONFIGSPATH)) {

    MessageBox(GetForegroundWindow(), _T("Failed to open registry key that contains current image parameters file path;")
                                      _T(" reverting to defaults."), _T("FURR - Error"), MB_OK | MB_ICONSTOP);

    GetAppPath(tsPath);
    tsPath += FURR_DEFIMAGEPARAMSFILE;

  }

  if (!Key.ReadString(FURR_CURIMAGEPARAMSVALUE, tsPath)) {

    MessageBox(GetForegroundWindow(), _T("Failed to read registry key that contains current image parameters file path;")
                                      _T(" reverting to defaults."), _T("FURR - Error"), MB_OK | MB_ICONSTOP);

    GetAppPath(tsPath);
    tsPath += FURR_DEFIMAGEPARAMSFILE;

  }

  if (_T("") == tsPath) {

    MessageBox(GetForegroundWindow(), _T("No current image parameters file is saved in the registry; reverting to defaults."),
                                      _T("FURR - Information"), MB_OK | MB_ICONINFORMATION);

    GetAppPath(tsPath);
    tsPath += FURR_DEFIMAGEPARAMSFILE;

  }

}
开发者ID:ryanlederman,项目名称:furr,代码行数:35,代码来源:adjustparams.cpp

示例3: mName

History::History (const char *name) : mName (name)
{
    if (name == 0)
	throw AppException (WHERE, ERR_INTERNAL);

    for (int i = 0; i < HIST_SIZE; i++)
	mpText[i] = 0;

    char subKey[256];
    strcpy (subKey, HKCU_SUBKEY_HERMIT "\\");
    strcat (subKey, mName);
    try {
	RegistryKey k (HKEY_CURRENT_USER, subKey, KEY_READ | KEY_WRITE);
	DWORD type;
	char str[3];
	for (int j = 0; j < HIST_SIZE; j++) {
	    wsprintf (str, "%d", j);
	    char *value = k.queryValue (str, type);
	    if (type == REG_SZ  &&  value != 0  &&  value[0] != '\0') {
		mpText[j] = _strdup (value);
		delete [] value;
		if (mpText[j] == 0)
		    throw AppException (WHERE, ERR_OUT_OF_MEMORY);
	    }
	    else {
		delete [] value;
		break;
	    }
	}
    }
    catch (const std::exception&) {
	// oh well, it's only the history
    }
}
开发者ID:ancientlore,项目名称:hermit,代码行数:34,代码来源:edit.cpp

示例4: SQLWriteDSNToIni

BOOL SQLWriteDSNToIni(
     LPCSTR   lpszDSN,
     LPCSTR   lpszDriver) {
  LoggerPtr logger = Logger::getLogger("install");
  LOG_DEBUG(logger, "received a call to SQLWriteDSNtoIni");

  BOOL rtnValue = FALSE;

  try {
    RegistryKey odbcIni(HKEY_CURRENT_USER, "Software\\ODBC\\ODBC.INI");

    string dsn(lpszDSN);
    RegistryKey driver = odbcIni.merge(dsn);

    // Driver / REG_SZ / location of driver
    const string driverLoc = install_path() + "o2jb.dll";
    size_t len = driverLoc.length();
    driver.set_value("Driver", REG_SZ, (BYTE*)driverLoc.c_str(), len);

    // SafeTransactions / REG_DWORD / 0
    int zero = 0;
    driver.set_value("SafeTransactions", REG_DWORD, (BYTE*)&zero, sizeof(zero));

    // Add the data source
    RegistryKey dataSrcs = odbcIni.merge("ODBC Data Sources");
    len = strlen(lpszDriver);
    dataSrcs.set_value(dsn, REG_SZ, (BYTE*)lpszDriver, len);

    rtnValue = TRUE;
  } catch (registry_exception& e) {
    LOG_FATAL(logger, string("Failed to create the keys:  ") + e.what());
  }
  return rtnValue;
}
开发者ID:austinarmbruster,项目名称:o2jb,代码行数:34,代码来源:o2jb_install.cpp

示例5: RegistryKey

RegistryKey *MainWindow::registerOptions()
{
	RegistryKey *r;
	RegistryKey *software = new RegistryKey(_T("HKEY_CURRENT_USER\\Software"));
	r = software->createSubKey(_T("Light Focus"));
	delete software;
	RegistryKey::Value *v;
	v = r->createValue(_T("SavePath"), REG_SZ);
	v->setString(_T("C:\\"));
	delete v;
	v = r->createValue(_T("HookPrintScreen"), REG_DWORD);
	v->setDword(1);
	delete v;
	v = r->createValue(_T("IncludeBackground"), REG_DWORD);
	v->setDword(0);
	delete v;
	v = r->createValue(_T("Delay"), REG_DWORD);
	v->setDword(0);
	delete v;
	v = r->createValue(_T("SaveType"), REG_DWORD);
	v->setDword(1);
	delete v;
	v = r->createValue(_T("CaptureMode"), REG_DWORD);
	v->setDword(1);
	delete v;
	r->refresh();
	return r;
}
开发者ID:nguyenkha,项目名称:light-focus,代码行数:28,代码来源:LightFocus.cpp

示例6: GetDWORD

	int RegistryKey::GetDWORD(HKEY key, tchar const *keyname, tchar const *valuename, uint32 &value)
	{
		RegistryKey bob;
		SXR(bob.Open(key, keyname));
		tstring path;
		SXR(bob.GetDWORDValue(valuename, value));
		return ERROR_SUCCESS;
	}
开发者ID:cskilbeck,项目名称:ShaderProcessor,代码行数:8,代码来源:Registry.cpp

示例7: getKey

void InitializeParameters::save() {
  RegistryKey key = getKey();

  key.setValue(_T("elementcount")    ,(UINT)m_elementCount          );
  key.setValue(_T("elementsize")     ,m_elementSize                 );
  key.setValue(_T("initmethod")      ,initMethodToName(m_initMethod));
  key.setValue(_T("randomize")       ,m_randomizationMethod         );
  key.setValue(_T("seed")            ,m_seed                        );
  key.setValue(_T("periodcount")     ,m_periodCount                 );
  key.setValue(_T("filename")        ,m_fileName                    );
}
开发者ID:JesperMikkelsen,项目名称:Big-Numbers,代码行数:11,代码来源:InitData.cpp

示例8: GetCurrentPreviewImage

void GetCurrentPreviewImage(TSTRING &tsImgPath) {


  RegistryKey Key;

  if (!Key.Create(FURR_ROOTREGISTRYKEY, FURR_REGISTRYCONFIGSPATH)) {

    MessageBox(GetForegroundWindow(), _T("Failed to open registry key that contains current preview image path!"),
                                      _T("FURR - Error"), MB_OK | MB_ICONSTOP);

  }

  Key.ReadString(FURR_CURPREVIEWIMAGEVALUE, tsImgPath);

}
开发者ID:ryanlederman,项目名称:furr,代码行数:15,代码来源:adjustparams.cpp

示例9: remove

	System::Void add_remove_contacts::remove()
	{
		label1->Visible = false;
		label2->Visible = false;
		label3->Visible = true;
		comboBox1->Visible = true;
		textBox1->Visible = false;
		textBox2->Visible = false;
		this->Text = "Apagar Contacto";
		add_or_remove = 1;
		RegistryKey * pRegKey = Registry::CurrentUser->OpenSubKey(L"Software\\Zip\\dotSMS\\Contacts" , true);
		if( pRegKey != NULL )
		{
			String* valueNames __gc [] = pRegKey->GetValueNames();
			comboBox1->Items->AddRange(valueNames);
		}
开发者ID:zipleen,项目名称:really-old-crap-from-cvs,代码行数:16,代码来源:add_remove_contacts.cpp

示例10: SetCurrentParamsPath

bool SetCurrentParamsPath(CTSTRING &tsPath) {

  bool r = false;
  RegistryKey Key;

  if (Key.Create(FURR_ROOTREGISTRYKEY, FURR_REGISTRYCONFIGSPATH)) {

    if (Key.WriteString(FURR_CURIMAGEPARAMSVALUE, tsPath)) {
    
      r = true;

    }

  }

  return r;
}
开发者ID:ryanlederman,项目名称:furr,代码行数:17,代码来源:adjustparams.cpp

示例11: CompareRegistryValue

gcc_pure
static bool
CompareRegistryValue(const RegistryKey &registry,
                     const TCHAR *name, const TCHAR *value)
{
  TCHAR real_value[64];
  return registry.GetValue(name, real_value, 64) &&
    StringIsEqualIgnoreCase(value, real_value);
}
开发者ID:DRIZO,项目名称:xcsoar,代码行数:9,代码来源:Enumerator.cpp

示例12: CompareRegistryValue

gcc_pure
static bool
CompareRegistryValue(const RegistryKey &registry,
                     const TCHAR *name, const TCHAR *value)
{
  TCHAR real_value[64];
  return registry.get_value(name, real_value, 64) &&
    _tcsicmp(value, real_value) == 0;
}
开发者ID:aharrison24,项目名称:XCSoar,代码行数:9,代码来源:Enumerator.cpp

示例13: InstallCommand

void CommandIgnore::InstallCommand(RegistryKey& configKey)
{
	vector<wstring> commands;
	wstring temp, entry;
	HidStatus status;

	temp.insert(0, m_targetImage.size() + HID_NORMALIZATION_OVERHEAD, L'\0');

	status = Hid_NormalizeFilePath(m_targetImage.c_str(), const_cast<wchar_t*>(temp.c_str()), temp.size());
	if (!HID_STATUS_SUCCESSFUL(status))
		throw WException(HID_STATUS_CODE(status), L"Error, can't normalize path, 'ignore' rejected");

	entry += temp.c_str();
	entry += L";";
	entry += ConvertInheritTypeToUnicode(m_inheritType);

	configKey.GetMultiStrValue(L"Hid_IgnoredImages", commands);
	commands.push_back(entry);
	configKey.SetMultiStrValue(L"Hid_IgnoredImages", commands);

	g_stderr << L"Install 'ignore' successful" << endl;
}
开发者ID:JKornev,项目名称:hidden,代码行数:22,代码来源:Ignore.cpp

示例14: RemoveSelectLetterCommandKeys

void RemoveSelectLetterCommandKeys()
{
	std::set<String, String::_CaseInsensitiveLess> classes;
	for each(const wchar_t *pExt in g_Extensions)
	{
		classes.insert(String::sFormat(L"BazisVirtualCD.%s", pExt));
		classes.insert(RegistryKey(HKEY_CLASSES_ROOT, String::sFormat(L".%s", pExt).c_str())[NULL]);
	}

	for each(const String &str in classes)
	{
		if (str.empty())
			continue;
		RegistryKey key(HKEY_CLASSES_ROOT, str.c_str());
		if (!key.Valid())
			continue;
		RegistryKey keyShell = key[L"shell"];
		if (keyShell.Valid())
			keyShell.DeleteSubKeyRecursive(L"Select drive letter && mount");
	}

}
开发者ID:ChuckNorrison,项目名称:WinCDEmu,代码行数:22,代码来源:uninstall.cpp

示例15: SQLRemoveDSNFromIni

BOOL SQLRemoveDSNFromIni(
     LPCSTR   lpszDSN) {
  LoggerPtr logger = Logger::getLogger("install");
  LOG_DEBUG(logger, "received a call to SQLRemoveDSNFromIni");

  BOOL rtnValue = FALSE;

  try {
    RegistryKey odbcIni(HKEY_CURRENT_USER, "Software\\ODBC\\ODBC.INI");

    // remove the data source tag
    RegistryKey dataSrcs = odbcIni.merge("ODBC Data Sources");
    dataSrcs.unset_value(lpszDSN);

    // remove the DSN tree
    odbcIni.remove(lpszDSN);

    rtnValue = TRUE;
  } catch (registry_exception& e) {
    LOG_FATAL(logger, string("Failed to create the keys:  ") + e.what());
  }
  return rtnValue;
}  
开发者ID:austinarmbruster,项目名称:o2jb,代码行数:23,代码来源:o2jb_install.cpp


注:本文中的RegistryKey类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。