• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ atl::CRegKey类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: TodayNotDo

BOOL AddinHelper::TodayNotDo(const wchar_t* szValueName)
{
	DWORD dwLastUTC = 0;
	BOOL bCando = FALSE;
	ATL::CRegKey key;
	if (key.Open(HKEY_CURRENT_USER, REGEDITPATH) == ERROR_SUCCESS) {
		bCando = TRUE;
		if(key.QueryDWORDValue(szValueName, dwLastUTC) == ERROR_SUCCESS) {
			__time64_t tTime = (__time64_t)dwLastUTC;
			tm* pTm = _localtime64(&tTime);
			LONG nLastDay = pTm->tm_mday;
			LONG nLastMonth = pTm->tm_mon;
			LONG nLastYear = pTm->tm_year;

			__time64_t lCurTime;
			_time64( &lCurTime); 
			tm* pTmc = _localtime64(&lCurTime);

			LONG nCurDay = pTmc->tm_mday;
			LONG nCurMonth = pTmc->tm_mon;
			LONG nCurYear = pTmc->tm_year;
			TSDEBUG4CXX("TodayHasDo check time pTmc = "<<nCurYear<<nCurMonth<<nCurDay<<", pTm = "<<nLastYear<<nLastMonth<<nLastDay);
			if (nCurDay == nLastDay && nCurMonth == nLastMonth && nCurYear == nLastYear){
				bCando = FALSE;
			}
			else{
				bCando = TRUE;
			}
		}
		key.Close();
	}
	return bCando;
}
开发者ID:fanliaokeji,项目名称:lvdun,代码行数:33,代码来源:AddinHelper.cpp


示例2: LoadMessageFilter

/// Loads a list of message IDs that should be passed on to the AOIA application
void LoadMessageFilter(HKEY hKeyParent, LPCTSTR lpszKeyName)
{
    g_messageFilter.empty();

    ATL::CRegKey reg;
    if (reg.Open(hKeyParent, lpszKeyName, KEY_READ) == ERROR_SUCCESS)
    {
        TCHAR subkey[256];
        DWORD skLength = 256;
        DWORD dw;
        int index = 0;

        while (true)
        {
            if (reg.EnumKey(index, subkey, &skLength) == ERROR_SUCCESS)
            {
                index++;
                if (reg.QueryDWORDValue(subkey, dw) == ERROR_SUCCESS)
                {
                    g_messageFilter.insert(dw);
                }
            }
            else
            {
                break;
            }
        }
    }
    else
    {
        LOG("Unable to open key: " << lpszKeyName)
    }
}
开发者ID:jellyfunk,项目名称:aoia-hack,代码行数:34,代码来源:dllmain.cpp


示例3: 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


示例4: GetGreenShiledExeFilePath

bool GetGreenShiledExeFilePath(wchar_t* buffer, std::size_t bufferLength)
{
	ATL::CRegKey key;
	if(key.Open(HKEY_LOCAL_MACHINE, L"Software\\ADClean", KEY_QUERY_VALUE) != ERROR_SUCCESS) {
		return false;
	}
	ULONG size = bufferLength;
	return key.QueryStringValue(L"Path", buffer, &size) == ERROR_SUCCESS;
}
开发者ID:fanliaokeji,项目名称:lvdun,代码行数:9,代码来源:Utility.cpp


示例5: AfxGetApp

CMainWizard::CMainWizard(CWnd* pOwnerWnd):
CCustomPropSheet(AFX_IDS_APP_TITLE, pOwnerWnd)
{
	CUpdateItApp* pApp = DYNAMIC_DOWNCAST(CUpdateItApp, AfxGetApp());
	ASSERT_VALID(pApp);

	// assign CRT locale
	static const TCHAR szDefLocale[] = _T("English_USA.1252");
	_tsetlocale(LC_ALL, pApp->GetProfileString(SZ_REGK_LOCALE, SZ_REGV_LOCALE_LC_ALL, szDefLocale));

	// load dialog's icons
	m_hIcon = pApp->LoadIcon(IDI_APP_ICON);
	m_hSmIcon = pApp->LoadSmIcon(MAKEINTRESOURCE(IDI_APP_ICON));

	static HYPERLINKCOLORS linkColors =
	{
		RGB(0, 0, 255),	// default
		RGB(0, 0, 255),	// active
		RGB(0, 0, 255),	// visited
		RGB(255, 0, 0)		// hover
	};
	CHyperLink::SetColors(linkColors);

	ATL::CRegKey regKeyLangs;
	regKeyLangs.Attach(pApp->GetSectionKey(SZ_REGK_LANGUAGES));

	int nError = ERROR_SUCCESS;

	if (static_cast<HKEY>(regKeyLangs) != NULL)
	{
		TCHAR szLangNames[128] = { 0 };
		ULONG cchNamesMax = _countof(szLangNames);
		nError = regKeyLangs.QueryStringValue(NULL, szLangNames, &cchNamesMax);
		if (nError == ERROR_SUCCESS)
		{
			LPCTSTR pszSeps = _T(",;\x20");
			LPTSTR pszCurLex = _tcstok(szLangNames, pszSeps);
			while (pszCurLex != NULL)
			{
				m_arrLangNames.Add(pszCurLex);
				pszCurLex = _tcstok(NULL, pszSeps);
			}
		}
		::RegCloseKey(regKeyLangs.Detach());
	}

	g_fRestartInterface = false;

	AddPage(&m_pageAbout);
	AddPage(&m_pageFirstLaunch);
	AddPage(&m_pageOptions);
	AddPage(&m_pageFiles);
	AddPage(&m_pageAction);
	AddPage(&m_pageProgress);

	SetWizardMode();
}
开发者ID:zephyrer,项目名称:update-it,代码行数:57,代码来源:MainWizard.cpp


示例6: Uninstall

BOOL CNTEventLogSource::Uninstall(LPCTSTR lpszLogName, LPCTSTR lpszSourceName)
{
  //Validate our parameters
  ATLASSUME(lpszLogName != NULL);
  ATLASSERT(_tcslen(lpszLogName));
  ATLASSUME(lpszSourceName != NULL);
  ATLASSERT(_tcslen(lpszSourceName));

  //Remove the settings from the registry
  TCHAR szSubKey[4096];
  _stprintf_s(szSubKey, sizeof(szSubKey)/sizeof(TCHAR), _T("SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s\\%s"), lpszLogName, lpszSourceName);
  long nSuccess = RegDeleteKey(HKEY_LOCAL_MACHINE, szSubKey);
  if (nSuccess != ERROR_SUCCESS) //If we cannot delete this registry key, then abort this function before we go any further
  {
    SetLastError(nSuccess); //Make the last error value available to our callers 
    return FALSE;
  }

  //Remove ourself from the "Sources" registry key
  _stprintf_s(szSubKey, sizeof(szSubKey)/sizeof(TCHAR), _T("SYSTEM\\CurrentControlSet\\Services\\EventLog\\%s"), lpszLogName);
  ATL::CRegKey appKey;
  if (appKey.Open(HKEY_LOCAL_MACHINE, szSubKey, KEY_WRITE | KEY_READ) == ERROR_SUCCESS)
  {
    CNTServiceStringArray sources;
    if (GetStringArrayFromRegistry(appKey, _T("Sources"), sources))
    {
      //If our name is in the array then remove it
      BOOL bFoundMyself = FALSE;

    #ifdef CNTSERVICE_MFC_EXTENSIONS
      for (int i=0; i<sources.GetSize() && !bFoundMyself; i++)
      {
        bFoundMyself = (sources.GetAt(i) == lpszSourceName);
        if (bFoundMyself)
        {
          sources.RemoveAt(i);
        }
      }
    #else
      CNTServiceStringArray::iterator iterFind = std::find(sources.begin(), sources.end(), lpszSourceName);
      bFoundMyself = (iterFind != sources.end());
      if (bFoundMyself)
        sources.erase(iterFind);
    #endif

      if (bFoundMyself)
        SetStringArrayIntoRegistry(appKey, _T("Sources"), sources);
    }
  }

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


示例7: readValue

std::wstring RegistryHelper::readValue(const LPTSTR valueName) const
{
    ATL::CRegKey regKey;
    unsigned long valSize = 0;
    std::wstring value;
    if (!(
            ERROR_SUCCESS == regKey.Open(key_, keyName_, KEY_READ) &&
            ERROR_SUCCESS == regKey.QueryStringValue(valueName, NULL, &valSize) && valSize > 0 &&
            (value.resize(valSize), ERROR_SUCCESS == regKey.QueryStringValue(valueName, (LPTSTR)value.data(), &valSize))
        ))
        value.clear();
    else
        value.resize(valSize - 1);
    return value;
}
开发者ID:averkhaturau,项目名称:InEfAn,代码行数:15,代码来源:win-reg.cpp


示例8: 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


示例9: 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


示例10: UnregisterAddin

static HRESULT UnregisterAddin(const std::wstring& clsid)
{
	HRESULT hr = S_OK;
	ATL::CRegKey key;

	//delete IconOverlay
	LSTATUS lStatus = key.Open(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ShellIconOverlayIdentifiers");
	if (lStatus == ERROR_SUCCESS) {
		lStatus = key.RecurseDeleteKey(L" DeskUpdateRemind");
		key.Close();
	}
	if (lStatus != ERROR_SUCCESS) {
		hr = HRESULT_FROM_WIN32(lStatus);
	}
	
	//delete CopyHook
	lStatus = key.Open(HKEY_CLASSES_ROOT, L"Directory\\shellex\\CopyHookHandlers");
	if (lStatus == ERROR_SUCCESS) {
		lStatus = key.RecurseDeleteKey(L"AYBSharing");
		key.Close();
	}
	if (lStatus != ERROR_SUCCESS) {
		hr = HRESULT_FROM_WIN32(lStatus);
	}

	//delete BHO
	//lStatus = key.Open(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Browser Helper Objects");
	//if (lStatus == ERROR_SUCCESS) {
	//	lStatus = key.RecurseDeleteKey(clsid.c_str());
	//	key.Close();
	//}
	//if (lStatus != ERROR_SUCCESS) {
	//	hr = HRESULT_FROM_WIN32(lStatus);
	//}

	//delete HKCR
	lStatus = key.Open(HKEY_CLASSES_ROOT, L"CLSID");
	if (lStatus == ERROR_SUCCESS) {
		lStatus = key.RecurseDeleteKey(clsid.c_str());
		key.Close();
	}
	if (lStatus != ERROR_SUCCESS) {
		hr = HRESULT_FROM_WIN32(lStatus);
	}

	return hr;
}
开发者ID:fanliaokeji,项目名称:lvdun,代码行数:47,代码来源:ExplorerAddin.cpp


示例11: UnregisterAddin

static HRESULT UnregisterAddin(const std::wstring& clsid)
{
	HRESULT hr = S_OK;
	ATL::CRegKey key;
	//delete BHO
	LSTATUS lStatus = key.Open(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Browser Helper Objects");
	if (lStatus == ERROR_SUCCESS) {
		lStatus = key.RecurseDeleteKey(clsid.c_str());
		key.Close();
	}
	if (lStatus != ERROR_SUCCESS) {
		hr = HRESULT_FROM_WIN32(lStatus);
	}

	//delete HKCR
	lStatus = key.Open(HKEY_CLASSES_ROOT, L"CLSID");
	if (lStatus == ERROR_SUCCESS) {
		lStatus = key.RecurseDeleteKey(clsid.c_str());
		key.Close();
	}
	if (lStatus != ERROR_SUCCESS) {
		hr = HRESULT_FROM_WIN32(lStatus);
	}

	return hr;
}
开发者ID:fanliaokeji,项目名称:lvdun,代码行数:26,代码来源:BhoAddin.cpp


示例12: 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


示例13: 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


示例14: 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


示例15: RegQueryValueString

BOOL ComPortDiscovery::RegQueryValueString(ATL::CRegKey& key, LPCTSTR lpValueName, LPTSTR& pszValue)
{
	//Initialize the output parameter
	pszValue = NULL;

	//First query for the size of the registry value 
	ULONG nChars = 0;
	LSTATUS nStatus = key.QueryStringValue(lpValueName, NULL, &nChars);
	if (nStatus != ERROR_SUCCESS)
	{
		SetLastError(nStatus);
		return FALSE;
	}

	//Allocate enough bytes for the return value
	DWORD dwAllocatedSize = ((nChars + 1) * sizeof(TCHAR)); //+1 is to allow us to NULL terminate the data if required
	pszValue = reinterpret_cast<LPTSTR>(LocalAlloc(LMEM_FIXED, dwAllocatedSize));
	if (pszValue == NULL)
		return FALSE;

	//We will use RegQueryValueEx directly here because ATL::CRegKey::QueryStringValue does not handle non-Null terminated data 
	DWORD dwType = 0;
	ULONG nBytes = dwAllocatedSize;
	pszValue[0] = _T('\0');
	nStatus = RegQueryValueEx(key, lpValueName, NULL, &dwType, reinterpret_cast<LPBYTE>(pszValue), &nBytes);
	if (nStatus != ERROR_SUCCESS)
	{
		LocalFree(pszValue);
		pszValue = NULL;
		SetLastError(nStatus);
		return FALSE;
	}
	if ((dwType != REG_SZ) && (dwType != REG_EXPAND_SZ))
	{
		LocalFree(pszValue);
		pszValue = NULL;
		SetLastError(ERROR_INVALID_DATA);
		return FALSE;
	}
	if ((nBytes % sizeof(TCHAR)) != 0)
	{
		LocalFree(pszValue);
		pszValue = NULL;
		SetLastError(ERROR_INVALID_DATA);
		return FALSE;
	}
	if (pszValue[(nBytes / sizeof(TCHAR)) - 1] != _T('\0'))
	{
		//Forcibly NULL terminate the data ourselves
		pszValue[(nBytes / sizeof(TCHAR))] = _T('\0');
	}

	return TRUE;
}
开发者ID:viaphonepayments,项目名称:ArduinoSerialCom,代码行数:54,代码来源:com_discovery.cpp


示例16: QueryRegVal

RegData AddinHelper::QueryRegVal(HKEY hkey, LPCTSTR lpszKeyName, LPCTSTR lpszValuename, REGSAM flag)
{
	ATL::CRegKey key;
	HRESULT hr;
	RegData rd;
	if ((hr = key.Open(hkey, lpszKeyName, flag)) == ERROR_SUCCESS) {
		TCHAR tszValue[MAX_PATH] = {0};
		ULONG lLen = MAX_PATH;
		DWORD dwInfo;
		if (key.QueryStringValue(lpszValuename, tszValue, &lLen) == ERROR_SUCCESS){
			std::wstring wstrInfo =  tszValue;
			rd.strData = wstrInfo;
		}
		else if((key.QueryDWORDValue(lpszValuename, dwInfo) == ERROR_SUCCESS)){
			rd.dwData = dwInfo;
		}
		
		key.Close();
	}
	return rd;
}
开发者ID:fanliaokeji,项目名称:lvdun,代码行数:21,代码来源:AddinHelper.cpp


示例17: IsPDFPrinterInstalled

bool IsPDFPrinterInstalled(std::tstring& stReason)
{
   const _bstr_t c_sAmynuProgId = _T("CDIntfEx.CDIntfEx");
   try
   {
      CLSID clsid = {0};
      HRESULT hr = CLSIDFromProgID(c_sAmynuProgId, &clsid);
      if (S_OK != hr)
         throw Workshare::Com::ComException(_T("PDF converter not installed."), hr);

      ATL::CRegKey printerRegistry;
      const TCHAR c_sRegistryKey[] = _T("Software\\Microsoft\\Windows NT\\CurrentVersion\\Devices\0");
      LONG lResult = printerRegistry.Open(HKEY_CURRENT_USER, c_sRegistryKey, KEY_READ);
      if(ERROR_SUCCESS != lResult)
      {
         CStdString sMessage;
         sMessage.Format(_T("Failed to open the key \"%s\" for reading the configured PDF printer"), c_sRegistryKey);
         throw Workshare::System::SystemException(_T("Failed to open the registry to read the configured PDF printer"), lResult);
      }

      TCHAR szData[MAX_PATH];
      ULONG ulSize(sizeof(szData)/sizeof(szData[0]));
      lResult = printerRegistry.QueryStringValue(c_sPDFDriverName, szData, &ulSize);
      if(ERROR_SUCCESS != lResult)
      {
         CStdString sMessage;
         sMessage.Format(_T("The PDF converter is not correctly installed. The printer \"%s\" needs to be installed. Rerun the installation of the PDF printer."), c_sPDFDriverName);
         throw Workshare::System::SystemException(sMessage.c_str(), lResult);
      }	
   }
   catch(const Workshare::Exception& e) 
   { 
      stReason = e.Message;
      return false;
   }
   catch(...) { unexpected(); }
   return true;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:38,代码来源:PrintingHelpers.cpp


示例18: OnLanguageChange

void CMainWizard::OnLanguageChange(UINT uMenuID)
{
	CUpdateItApp* pApp = DYNAMIC_DOWNCAST(CUpdateItApp, AfxGetApp());
	ASSERT_VALID(pApp);

	ATL::CRegKey regKeyLangs;
	regKeyLangs.Attach(pApp->GetSectionKey(SZ_REGK_LANGUAGES));

	int nError = ERROR_SUCCESS;

	if (static_cast<HKEY>(regKeyLangs) != NULL)
	{
		UINT iLangName = uMenuID - ((ID_LANGUAGE_ENGLISH & 0x00F0) >> 4);
		nError = regKeyLangs.SetStringValue(SZ_REGV_LANGUAGES_CURRENT, m_arrLangNames[iLangName]);
		if (nError == ERROR_SUCCESS)
		{
			CheckLangMenuItem(iLangName);
			regKeyLangs.Flush();
			g_fRestartInterface = true;
			PostMessage(PSM_PRESSBUTTON, PSBTN_CANCEL, 0);
		}
		::RegCloseKey(regKeyLangs.Detach());
	}
开发者ID:zephyrer,项目名称:update-it,代码行数:23,代码来源:MainWizard.cpp


示例19: 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


示例20: OnBnClickedButtonReload

void CFileTypesForm::OnBnClickedButtonReload()
{
    for (DWORD i=0; i<pageCount; i++)
    {
        if (pages[i])
        {
            pages[i]->info.Clear();
            pages[i]->UpdateTree();
        }
    }

    DSUtil::FilterTemplates filters;
    filters.EnumerateAllRegisteredFilters();

    // search for registered protocols
    if (page_protocols)
    {
        ATL::CRegKey rkRoot(HKEY_CLASSES_ROOT);
        // only real protocols => not something like "WMP11.AssocProtocol.MMS"
        // faster, because i don't need to search in every entry for "Source Filter"
        TCHAR szName[10] = {0};
        DWORD szNameLength = 10;
        DWORD i = 0;
        long ret = 0;
        while (ERROR_NO_MORE_ITEMS != (ret = rkRoot.EnumKey(i++, szName, &szNameLength)))
        {
            if (ret != ERROR_SUCCESS)
                continue;

            CRegKey rkKey;
            if(ERROR_SUCCESS == rkKey.Open(HKEY_CLASSES_ROOT, szName, KEY_READ))
            {
                TCHAR szSourceFilterGuid[40] = {0};
                DWORD szLength = 40;
                if (ERROR_SUCCESS == rkKey.QueryStringValue(_T("Source Filter"), szSourceFilterGuid, &szLength))
                {
                    GraphStudio::PropItem* group = new GraphStudio::PropItem(CString(szName));

                    CString strClsid = szSourceFilterGuid;
                    GUID clsid = {0};
                    CLSIDFromString((LPOLESTR)strClsid.GetBuffer(), &clsid);

                    group->AddItem(new GraphStudio::PropItem(_T("CLSID"), CString(szSourceFilterGuid), false));

                    DSUtil::FilterTemplate ft;
		            if (filters.FindTemplateByCLSID(clsid, &ft))
                    {
                        group->AddItem(new GraphStudio::PropItem(_T("Name"), CString(ft.name), false));
                        group->AddItem(new GraphStudio::PropItem(_T("File"), CString(ft.file), false));
                    }

                    // last Change of this key
                    FILETIME timeMod = {0};
                    if (ERROR_SUCCESS == RegQueryInfoKey(rkKey, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &timeMod))
                        group->AddItem(new GraphStudio::PropItem(_T("Modified"), CTime(timeMod)));

                    page_protocols->info.AddItem(group);
                }
            }
            rkKey.Close();
            szNameLength = 10;
        }
        page_protocols->UpdateTree();
        rkRoot.Close();
    }

    // search for registered extensions
    if (page_extensions)
    {
        ATL::CRegKey rkRoot;
        CString strRoot = _T("Media Type\\Extensions");
        if (ERROR_SUCCESS == rkRoot.Open(HKEY_CLASSES_ROOT, strRoot, KEY_READ))
        {
            // {7DF62B50-6843-11D2-9EEB-006008039E37}
            static const GUID CLSID_StillVideo = {0x7DF62B50, 0x6843, 0x11D2, { 0x9E, 0xEB, 0x00, 0x60, 0x08, 0x03, 0x9E, 0x37} };

            TCHAR szName[50] = {0};
            DWORD szNameLength = 50;
            DWORD i = 0;
            while (ERROR_NO_MORE_ITEMS != rkRoot.EnumKey(i++, szName, &szNameLength))
            {
                CString strKey = strRoot;
                strKey.Append(_T("\\"));
                strKey.Append(szName);
                CRegKey rkKey;
                if(ERROR_SUCCESS == rkKey.Open(HKEY_CLASSES_ROOT, strKey, KEY_READ))
                {
                    GraphStudio::PropItem* group = new GraphStudio::PropItem(CString(szName));

                    TCHAR szGuid[40] = {0};
                    DWORD szLength = 40;
                    if (ERROR_SUCCESS == rkKey.QueryStringValue(_T("Source Filter"), szGuid, &szLength))
                    {
                        CString strClsid = szGuid;
                        GUID clsid = {0};
                        CLSIDFromString((LPOLESTR)strClsid.GetBuffer(), &clsid);
                        group->AddItem(new GraphStudio::PropItem(_T("CLSID"), CString(szGuid), false));

                        DSUtil::FilterTemplate ft;
		                if (filters.FindTemplateByCLSID(clsid, &ft))
//.........这里部分代码省略.........
开发者ID:EnigmaIndustries,项目名称:graph-studio-next,代码行数:101,代码来源:FileTypesForm.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ atl::CString类代码示例发布时间:2022-05-31
下一篇:
C++ atl::CHeapPtr类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap