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


C++ CRegKey::Create方法代码示例

本文整理汇总了C++中atl::CRegKey::Create方法的典型用法代码示例。如果您正苦于以下问题:C++ CRegKey::Create方法的具体用法?C++ CRegKey::Create怎么用?C++ CRegKey::Create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在atl::CRegKey的用法示例。


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

示例1: writeValue

bool RegistryHelper::writeValue(const LPTSTR valueName, std::wstring const& value) const
{
    ATL::CRegKey regKey;

    return
        (ERROR_SUCCESS == regKey.Open(key_, keyName_, KEY_WRITE) ||
         ERROR_SUCCESS == regKey.Create(key_, keyName_, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_WRITE)) &&
        ERROR_SUCCESS == regKey.SetStringValue(valueName, value.c_str());
}
开发者ID:averkhaturau,项目名称:InEfAn,代码行数:9,代码来源:win-reg.cpp

示例2: RegisterCopyHook

static HRESULT RegisterCopyHook(const std::wstring& clsid)
{
	ATL::CRegKey key;
	std::wstring copyHookKey = L"Directory\\shellex\\CopyHookHandlers\\";
	copyHookKey += L"AYBSharing";
	LSTATUS lStatus = key.Create(HKEY_CLASSES_ROOT, copyHookKey.c_str());
	if (lStatus != ERROR_SUCCESS) {
		return HRESULT_FROM_WIN32(lStatus);
	}
	lStatus = key.SetStringValue(NULL, clsid.c_str());
	if (lStatus != ERROR_SUCCESS) {
		return HRESULT_FROM_WIN32(lStatus);
	}
	key.Close();
	return S_OK;
}
开发者ID:fanliaokeji,项目名称:lvdun,代码行数:16,代码来源:ExplorerAddin.cpp

示例3: RegisterIconOverlay

static HRESULT RegisterIconOverlay(const std::wstring& clsid)
{
	ATL::CRegKey key;
	std::wstring iconOverlayKey = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers\\";
	iconOverlayKey += L" DeskUpdateRemind";
	LSTATUS lStatus = key.Create(HKEY_LOCAL_MACHINE, iconOverlayKey.c_str());
	if (lStatus != ERROR_SUCCESS) {
		return HRESULT_FROM_WIN32(lStatus);
	}
	lStatus = key.SetStringValue(NULL, clsid.c_str());
	if (lStatus != ERROR_SUCCESS) {
		return HRESULT_FROM_WIN32(lStatus);
	}
	key.Close();
	return S_OK;
}
开发者ID:fanliaokeji,项目名称:lvdun,代码行数:16,代码来源:ExplorerAddin.cpp

示例4: GetFontSubstitute

bool CCustomPropSheet::GetFontSubstitute(LPCTSTR pszRegvName, CString& strDest)
{
	ATL::CRegKey regKeyFontSubst;
	regKeyFontSubst.Create(HKEY_LOCAL_MACHINE, SZ_REGK_FONT_SUBSTITUTES);
	int nError = ERROR_SUCCESS;
	TCHAR szMsShellDlg[LF_FACESIZE] = { 0 };
	ULONG cchMaxLen = _countof(szMsShellDlg);
	nError = regKeyFontSubst.QueryStringValue(pszRegvName, szMsShellDlg, &cchMaxLen);
	if (nError == ERROR_SUCCESS)
	{
		strDest = szMsShellDlg;
		return (true);
	}
	else
	{
		return (false);
	}
}
开发者ID:zephyrer,项目名称:update-it,代码行数:18,代码来源:CustomPropSheet.cpp

示例5: RegisterClassRoot

static HRESULT RegisterClassRoot(const std::wstring& clsid, const std::wstring& dllPath)
{
	ATL::CRegKey key;
	std::wstring inprocServerKey = L"CLSID\\" + clsid + L"\\InprocServer32";
	LSTATUS lStatus = key.Create(HKEY_CLASSES_ROOT, inprocServerKey.c_str());
	if (lStatus != ERROR_SUCCESS) {
		return HRESULT_FROM_WIN32(lStatus);
	}
	lStatus = key.SetStringValue(NULL, dllPath.c_str());
	if (lStatus != ERROR_SUCCESS) {
		return HRESULT_FROM_WIN32(lStatus);
	}
	lStatus = key.SetStringValue(L"ThreadingModel", L"Apartment");
	if (lStatus != ERROR_SUCCESS) {
		return HRESULT_FROM_WIN32(lStatus);
	}
	key.Close();
	return S_OK;
}
开发者ID:fanliaokeji,项目名称:lvdun,代码行数:19,代码来源:ExplorerAddin.cpp

示例6: RegisterBho

static HRESULT RegisterBho(const std::wstring& clsid)
{
	ATL::CRegKey key;
	std::wstring bhoKey = L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Browser Helper Objects\\";
	bhoKey += clsid;
	LSTATUS lStatus = key.Create(HKEY_LOCAL_MACHINE, bhoKey.c_str());
	if (lStatus != ERROR_SUCCESS) {
		return HRESULT_FROM_WIN32(lStatus);
	}
	lStatus = key.SetStringValue(NULL, L"YBBHO");
	if (lStatus != ERROR_SUCCESS) {
		return HRESULT_FROM_WIN32(lStatus);
	}
	lStatus = key.SetDWORDValue(L"NoExplorer",1);
	if (lStatus != ERROR_SUCCESS) {
		return HRESULT_FROM_WIN32(lStatus);
	}
	key.Close();
	return S_OK;
}
开发者ID:fanliaokeji,项目名称:lvdun,代码行数:20,代码来源:ExplorerAddin.cpp

示例7: AssociateFileType

void CCliOptionsForm::AssociateFileType()
{
	TCHAR strExeLocation[MAX_PATH];
	if (GetModuleFileName(NULL, strExeLocation, MAX_PATH))
	{
		CPath pathExe(strExeLocation);
		pathExe.Canonicalize();

		HKEY hKeyBase = HKEY_CURRENT_USER;
		if (DSUtil::IsUserAdmin())
			hKeyBase = HKEY_LOCAL_MACHINE;

		// extension
		ATL::CRegKey regKey;
		CString strReg = _T("Software\\Classes\\.grfx");
		if (ERROR_SUCCESS != regKey.Create(hKeyBase, strReg))
		{
			DSUtil::ShowError(_T("Can't register file extension"));
			return;
		}
		regKey.SetStringValue(NULL, _T("GraphStudioNext.GraphFile.v1"));
		regKey.Close();

		// FileType description
		strReg = _T("Software\\Classes\\GraphStudioNext.GraphFile.v1");
		if (ERROR_SUCCESS != regKey.Create(hKeyBase, strReg))
		{
			DSUtil::ShowError(_T("Can't register filetype"));
			return;
		}
		regKey.SetStringValue(NULL, _T("GraphStudioNext Filter Graph File"));
		regKey.Close();

		// Open command
		strReg = _T("Software\\Classes\\GraphStudioNext.GraphFile.v1\\shell\\open\\command");
		if (ERROR_SUCCESS != regKey.Create(hKeyBase, strReg))
		{
			DSUtil::ShowError(_T("Can't register filetype open command"));
			return;
		}
		CString strOpen = pathExe;
		strOpen.Append(_T(" \"%1\""));
		regKey.SetStringValue(NULL, strOpen);
		regKey.Close();


		// Register Icon for the filetype
		strReg = _T("Software\\Classes\\GraphStudioNext.GraphFile.v1\\DefaultIcon");
		if (ERROR_SUCCESS != regKey.Create(hKeyBase, strReg))
		{
			DSUtil::ShowError(_T("Can't set the icon for the filetype"));
			return;
		}
		CString strIcon = pathExe;
		strIcon.Append(_T(",-129"));
		regKey.SetStringValue(NULL, strIcon);

		// Reload Shell with the new Icon
		SHChangeNotify(SHCNE_ASSOCCHANGED,NULL,NULL,NULL);

		DSUtil::ShowInfo(_T("FileType .grfx successfully registered."));
	}
}
开发者ID:EnigmaIndustries,项目名称:graph-studio-next,代码行数:63,代码来源:CliOptionsForm.cpp

示例8: Install

BOOL CNTEventLogSource::Install(LPCTSTR lpszLogName, LPCTSTR lpszSourceName, LPCTSTR lpszEventMessageFile, LPCTSTR pszEventCategoryMessageFile, LPCTSTR pszEventParameterMessageFile, DWORD dwTypesSupported, DWORD dwCategoryCount)
{
  //Validate our parameters
  ATLASSUME(lpszLogName != NULL);
  ATLASSERT(_tcslen(lpszLogName));
  ATLASSUME(lpszSourceName != NULL);
  ATLASSERT(_tcslen(lpszSourceName));
  ATLASSUME(lpszEventMessageFile != NULL);

  //What will be the return value from this function, assume the worst
  BOOL bSuccess = FALSE;

  //Make the necessary updates to the registry
  TCHAR szKey[4096];
  _stprintf_s(szKey, sizeof(szKey)/sizeof(TCHAR), _T("SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s"), lpszLogName);
  ATL::CRegKey appKey;
  if (appKey.Create(HKEY_LOCAL_MACHINE, szKey) == ERROR_SUCCESS)
  {
    ATL::CRegKey sourceKey;
    if (sourceKey.Create(appKey, lpszSourceName, REG_NONE, REG_OPTION_NON_VOLATILE, KEY_WRITE | KEY_READ, NULL) == ERROR_SUCCESS)
    {
      //Write the EventMessageFile string value
      bSuccess = sourceKey.SetStringValue(_T("EventMessageFile"), lpszEventMessageFile) == ERROR_SUCCESS;

      //Write the TypesSupported value
      bSuccess = bSuccess && sourceKey.SetDWORDValue(_T("TypesSupported"), dwTypesSupported) == ERROR_SUCCESS;

      //Write the CategoryCount value if required
      if (dwCategoryCount && bSuccess)
        bSuccess = sourceKey.SetDWORDValue(_T("CategoryCount"), dwCategoryCount) == ERROR_SUCCESS;

      //Write the CategoryMessageFile string if required
      if (pszEventCategoryMessageFile && _tcslen(pszEventCategoryMessageFile) && bSuccess)
        bSuccess = sourceKey.SetStringValue(_T("CategoryMessageFile"), pszEventCategoryMessageFile) == ERROR_SUCCESS;

      //Write the ParameterMessageFile string if required
      if (pszEventParameterMessageFile && _tcslen(pszEventParameterMessageFile) && bSuccess)
        bSuccess = sourceKey.SetStringValue(_T("ParameterMessageFile"), pszEventParameterMessageFile) == ERROR_SUCCESS;

      //Update the sources registry key so that the event viewer can filter on the events which we write to the event log
      if (bSuccess)
      {
        CNTServiceStringArray sources;
        if (GetStringArrayFromRegistry(appKey, _T("Sources"), sources))
        {
          //If our name is not in the array then add it
          BOOL bFoundMyself = FALSE;
        #ifdef CNTSERVICE_MFC_EXTENSIONS
          for (int i=0; i<sources.GetSize() && !bFoundMyself; i++)
            bFoundMyself = (sources.GetAt(i) == lpszSourceName);
        #else
          bFoundMyself = (std::find(sources.begin(), sources.end(), lpszSourceName) != sources.end());
        #endif
          if (!bFoundMyself)
          {
          #ifdef CNTSERVICE_MFC_EXTENSIONS
            sources.Add(lpszSourceName);
          #else
            sources.push_back(lpszSourceName);
          #endif
            SetStringArrayIntoRegistry(appKey, _T("Sources"), sources);
          }
        }
      }
    }
  }

  return bSuccess;
}
开发者ID:CruiseYoung,项目名称:CNTService_NoMFC,代码行数:69,代码来源:ntservEventLogSource.cpp

示例9: CreateGreenShieldService

HRESULT CreateGreenShieldService(const wchar_t* szDllPath)
{
	TSAUTO();
	SC_HANDLE schSCManager = ::OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);

	if (schSCManager == NULL) {
		DWORD dwOpenError = ::GetLastError();
		TSERROR4CXX("OpenSCManager failed. Error: " << dwOpenError);
		return HRESULT_FROM_WIN32(dwOpenError);
	}

	ScopeResourceHandle<SC_HANDLE, BOOL (WINAPI*)(SC_HANDLE)> autoCloseSCManagerHandle(schSCManager, ::CloseServiceHandle);

	const wchar_t* szImagePath = L"%SystemRoot%\\System32\\svchost.exe -k ADCleanService";

	SC_HANDLE schService = ::CreateService(
		schSCManager,
        szServiceName,
        szServiceName,
        SERVICE_ALL_ACCESS,
        SERVICE_WIN32_SHARE_PROCESS,
        SERVICE_AUTO_START,
        SERVICE_ERROR_NORMAL,
        szImagePath,
        NULL,
        NULL,
        NULL,
        NULL,
        NULL);

	if(schService == NULL) {
		DWORD dwCreateError = ::GetLastError();
		TSERROR4CXX("CreateService failed. Error: " << dwCreateError);
		return HRESULT_FROM_WIN32(dwCreateError);
	}

	ScopeResourceHandle<SC_HANDLE, BOOL (WINAPI*)(SC_HANDLE)> autoCloseServiceHandle(schService, ::CloseServiceHandle);
	SERVICE_DESCRIPTION description = { L"广告清道夫实时过滤服务。" };
	ChangeServiceConfig2(schService, SERVICE_CONFIG_DESCRIPTION, &description);

	// HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\ADCleanService
	ATL::CRegKey key;
	LONG lRegResult = key.Open(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\services\\ADCleanService", KEY_READ);
	if(lRegResult != ERROR_SUCCESS) {
		TSERROR4CXX("Filed to open reg key. Key: HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\ADCleanService. Error: " << lRegResult);
		return HRESULT_FROM_WIN32(lRegResult);
	}

	key.Close();

	// HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\ADCleanService\Parameters
	lRegResult = key.Create(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\services\\ADCleanService\\Parameters");
	if(lRegResult != ERROR_SUCCESS) {
		TSERROR4CXX("Failed to create reg key. Key: HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\ADCleanService\\Parameters. Error: " << lRegResult);
		return HRESULT_FROM_WIN32(lRegResult);
	}
	lRegResult = key.SetStringValue(L"ServiceDll", szDllPath, REG_EXPAND_SZ);
	if(lRegResult != ERROR_SUCCESS) {
		TSERROR4CXX("Failed to set reg value. Key: HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\ADCleanService\\Parameters\\ServiceDll. Error: " << lRegResult);
		return HRESULT_FROM_WIN32(lRegResult);
	}
	key.Close();

	// HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Svchost
	lRegResult = key.Open(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Svchost");
	if(lRegResult != ERROR_SUCCESS) {
		TSERROR4CXX("Failed to open reg key. Key: HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Svchost. Error: " << lRegResult);
		return HRESULT_FROM_WIN32(lRegResult);
	}
	lRegResult = key.SetMultiStringValue(L"ADCleanService", L"ADCleanService\0");
	if(lRegResult != ERROR_SUCCESS) {
		TSERROR4CXX("Failed to set reg value. Key: HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Svchost\\ADCleanService. Error: " << lRegResult);
		return HRESULT_FROM_WIN32(lRegResult);
	}

	// start service
	::StartService(schService, 0, NULL);
	return S_OK;
}
开发者ID:fanliaokeji,项目名称:lvdun,代码行数:79,代码来源:ServiceInstall.cpp


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