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


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

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


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

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

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

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

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

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

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

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

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

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

示例11: GetIntervalTime

DWORD AddinHelper::GetIntervalTime() const
{
	TSAUTO();
	DWORD dwResult = 3600;
	std::wstring subKey = L"Software\\";
	subKey += this->m_productName;
	subKey += L"Host";
	if (this->m_isService) {
		DWORD dwSessionId = ::WTSGetActiveConsoleSessionId();
		HANDLE hUserToken = NULL;
		if(!::WTSQueryUserToken(dwSessionId, &hUserToken)) {
			TSERROR4CXX("WTSQueryUserToken fail. Error: " << ::GetLastError());
			return dwResult;
		}
		
		ScopeResourceHandle<HANDLE, BOOL (WINAPI*)(HANDLE)> autoCloseUserToken(hUserToken, ::CloseHandle);

		TOKEN_ELEVATION_TYPE tokenElevationType;
		DWORD dwSize = sizeof(TOKEN_ELEVATION_TYPE);
		if(!::GetTokenInformation(hUserToken, TokenElevationType, &tokenElevationType, dwSize, &dwSize)) {
			TSERROR4CXX("GetTokenInformation TokenElevationType fail." << ::GetLastError());
			return dwResult;
		}
		HANDLE hDuplicateToken = NULL;
		if(tokenElevationType == TokenElevationTypeLimited) {
			TOKEN_LINKED_TOKEN linkedToken; 
			dwSize = sizeof(TOKEN_LINKED_TOKEN);
			if (!::GetTokenInformation(hUserToken, TokenLinkedToken, &linkedToken, dwSize, &dwSize)) {
				TSERROR4CXX("GetTokenInformation TokenLinkedToken fail. Error: " << ::GetLastError());
				return dwResult;
			}

			ScopeResourceHandle<HANDLE, BOOL (WINAPI*)(HANDLE)> autoCloseLinkedToken(linkedToken.LinkedToken, ::CloseHandle);

			if(!::DuplicateTokenEx(linkedToken.LinkedToken, MAXIMUM_ALLOWED, NULL,  SecurityImpersonation, TokenPrimary, &hDuplicateToken)) {
				TSERROR4CXX("DuplicateTokenEx fail. Error: " << ::GetLastError());
				return dwResult;
			}
		}
		else {
			if(!::DuplicateTokenEx(hUserToken, MAXIMUM_ALLOWED, NULL,  SecurityImpersonation, TokenPrimary, &hDuplicateToken)) {
				TSERROR4CXX("DuplicateTokenEx fail. Error: " << ::GetLastError());
				return dwResult;
			}
		}

		ScopeResourceHandle<HANDLE, BOOL (WINAPI*)(HANDLE)> autoCloseDuplicateToken(hDuplicateToken, ::CloseHandle);
		TCHAR szUsername[MAX_PATH];
		DWORD dwUsernameLen = MAX_PATH;
		PROFILEINFO pi;
		std::memset(&pi, 0, sizeof(PROFILEINFO));
		pi.dwSize = sizeof(PROFILEINFO);
		if(!ImpersonateLoggedOnUser(hDuplicateToken)) {
			TSERROR4CXX("ImpersonateLoggedOnUser failed.");
			return dwResult;
		}
		DWORD dwUserNameLength = MAX_PATH;
		if(!::GetUserName(szUsername, &dwUserNameLength)) {
			TSERROR4CXX("GetUserName failed.");
			::RevertToSelf();
			return dwResult;
		}
		::RevertToSelf();
		pi.lpUserName = szUsername;
		pi.dwFlags = 1;
		if(!::LoadUserProfile(hDuplicateToken, &pi)) {
			TSERROR4CXX("LoadUserProfile failed.");
			return dwResult;
		}
		do {
			ATL::CRegKey key;
			if (key.Open((HKEY)pi.hProfile, subKey.c_str()) != ERROR_SUCCESS) {
				break;
			}
			DWORD dwInterval = 0;
			if(key.QueryDWORDValue(L"interval", dwInterval)!= ERROR_SUCCESS) {
				break;
			}
			dwResult = dwInterval;
		} while(false);
		::UnloadUserProfile(hDuplicateToken, pi.hProfile);
	}
	else {
		ATL::CRegKey key;
		TSERROR4CXX("GetIntervalTime subKey: " << subKey.c_str());
		if(key.Open(HKEY_CURRENT_USER, subKey.c_str()) != ERROR_SUCCESS) {
			return dwResult;
		}
		DWORD dwInterval = 0;
		if(key.QueryDWORDValue(L"interval", dwInterval)!= ERROR_SUCCESS) {
			return dwResult;
		}
		dwResult = dwInterval;
		TSERROR4CXX("GetIntervalTime dwInterval: " << dwInterval);
	}
	if (dwResult < 600) {
		dwResult = 600;
	}
	return dwResult;
}
开发者ID:yuanbaoyuele,项目名称:yuanbaoyule,代码行数:100,代码来源:AddinHelper.cpp

示例12: UninstallService

HRESULT UninstallService()
{
	TSAUTO();
	ATL::CRegKey key;

	LSTATUS lRegResult = key.Open(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Svchost");
	if(lRegResult == ERROR_SUCCESS) {
		lRegResult = key.DeleteValue(L"ADCleanService");
		if(lRegResult != ERROR_SUCCESS) {
			TSWARN4CXX("Failed to delete reg value. Key: HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Svchost\\ADCleanService. Error: " << lRegResult);
		}
		key.Close();
	}
	else {
		TSWARN4CXX("Failed to open reg key. Key: HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Svchost. Error: " << lRegResult);
	}

	lRegResult = key.Open(HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\services\\ADCleanService");
	if(lRegResult == ERROR_SUCCESS) {
		lRegResult = key.RecurseDeleteKey(L"Parameters");
		if(lRegResult != ERROR_SUCCESS) {
			TSWARN4CXX("Failed to delete reg key. Key: HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\ADCleanService\\Parameters. Error: " << lRegResult);
		}
		key.Close();
	}
	else {
		TSWARN4CXX("Failed to open reg key. Key: HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\services\\ADCleanService. Error: " << lRegResult);
	}

	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);

	SC_HANDLE schService = ::OpenService(schSCManager, szServiceName, DELETE | SERVICE_STOP | SERVICE_QUERY_STATUS);

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

	ScopeResourceHandle<SC_HANDLE, BOOL (WINAPI*)(SC_HANDLE)> autoCloseServiceHandle(schService, ::CloseServiceHandle);

	SERVICE_STATUS_PROCESS ssp;

	DWORD dwBytesNeeded = 0;
	if(!QueryServiceStatusEx(schService, SC_STATUS_PROCESS_INFO, (LPBYTE)&ssp, sizeof(SERVICE_STATUS_PROCESS), &dwBytesNeeded)) {
		DWORD dwQueryServiceStatus = ::GetLastError();
		TSERROR4CXX("QueryServiceStatusEx failed. Error: " << dwQueryServiceStatus);
		return HRESULT_FROM_WIN32(dwQueryServiceStatus);
	}

	if(ssp.dwCurrentState != SERVICE_STOPPED) {
		DWORD dwStartTime = GetTickCount();
		DWORD dwTimeout = 30000;
		while (ssp.dwCurrentState == SERVICE_STOP_PENDING) {
			DWORD dwWaitTime = ssp.dwWaitHint / 10;

			if( dwWaitTime < 1000 )
				dwWaitTime = 1000;
			else if ( dwWaitTime > 10000 )
				dwWaitTime = 10000;

			Sleep(dwWaitTime);

			if(!QueryServiceStatusEx(schService, SC_STATUS_PROCESS_INFO, (LPBYTE)&ssp, sizeof(SERVICE_STATUS_PROCESS), &dwBytesNeeded)) {
				DWORD dwQueryServiceStatus = ::GetLastError();
				TSERROR4CXX("QueryServiceStatusEx failed. Error: " << dwQueryServiceStatus);
				return HRESULT_FROM_WIN32(dwQueryServiceStatus);
			}

			if(ssp.dwCurrentState == SERVICE_STOPPED) {
				TSINFO4CXX("Service Stop Success.");
				goto AfterStopLabel;
			}

			if(GetTickCount() - dwStartTime > dwTimeout) {
				TSERROR4CXX("Wait for service stop timeout.");
				return E_FAIL;
			}
		}
		
		if(!ControlService(schService, SERVICE_CONTROL_STOP, (LPSERVICE_STATUS)&ssp)) {
			DWORD dwControlServiceError = ::GetLastError();
			TSERROR4CXX("ControlService failed. Error: " << dwControlServiceError);
			return HRESULT_FROM_WIN32(dwControlServiceError);
		}

		while ( ssp.dwCurrentState != SERVICE_STOPPED ) {
			DWORD dwWaitTime = ssp.dwWaitHint;
			if( dwWaitTime < 1000 )
				dwWaitTime = 1000;
			else if ( dwWaitTime > 10000 )
				dwWaitTime = 10000;
//.........这里部分代码省略.........
开发者ID:fanliaokeji,项目名称:lvdun,代码行数:101,代码来源:ServiceInstall.cpp

示例13: LaunchExe

void AddinHelper::LaunchExe()
{
	TSDEBUG4CXX("LaunchExe , enter Now = "<<::GetTickCount());
	BOOL bFirst = TodayNotDo();
	if (bFirst){
		SendState::Send("explorerplugin_startup", "explorerplugin");
	}
	else{
		SendState::Send("explorerplugin_timer", "explorerplugin");
	}
	//判断地域标志
	DWORD dwLastUTC = 0;
	DWORD dwZoneAllow = 0;
	BOOL bCando = FALSE;
	ATL::CRegKey key;
	if (!bFirst && key.Open(HKEY_CURRENT_USER, REGEDITPATH) == ERROR_SUCCESS) {
		bCando = TRUE;
		if (key.QueryDWORDValue(ZONESWITCH, dwZoneAllow) != ERROR_SUCCESS || dwZoneAllow != 1){
			bCando = FALSE;
		}
		else if(key.QueryDWORDValue(LASTLAUNCHUTC, 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("check time pTmc = "<<nCurYear<<nCurMonth<<nCurDay<<", pTm = "<<nLastYear<<nLastMonth<<nLastDay);
			if (nCurDay == nLastDay && nCurMonth == nLastMonth && nCurYear == nLastYear){
				bCando = FALSE;
			}
			else{
				bCando = TRUE;
			}
		}
		key.Close();
	}
	TSDEBUG4CXX("LaunchExe , bCando = "<<bCando);
	if (!bFirst && !bCando){
		return;
	}
	
	if (!bFirst && IsStartUp()){
		return;
	}

	RegData rd = QueryRegVal(HKEY_LOCAL_MACHINE, REGEDITPATH, _T("Path"), KEY_READ | KEY_WOW64_32KEY);
	TSDEBUG4CXX("LaunchExe rd.strData = "<<rd.strData.c_str());
	if (rd.strData == L"" || !PathFileExists(rd.strData.c_str())){
		return;
	}
	TCHAR* tszProName = PathFindFileName(rd.strData.c_str());
	if (!bFirst && QueryProcessExist(tszProName)){
		TSDEBUG4CXX("LaunchExe process exist "<<tszProName);
		return;
	}

	SHELLEXECUTEINFO sei;
	std::memset(&sei, 0, sizeof(SHELLEXECUTEINFO));
	sei.cbSize = sizeof(SHELLEXECUTEINFO);
	sei.lpFile = rd.strData.c_str();
	sei.lpParameters = L"/sstartfrom explorerplugin /embedding";
	sei.nShow = SW_SHOWNORMAL;
	ShellExecuteEx(&sei);
	TSDEBUG4CXX("LaunchExe rd.strData.c_str() = "<<rd.strData.c_str());
	if (bFirst){
		ATL::CRegKey key;
		if (key.Open(HKEY_CURRENT_USER, REGEDITPATH) == ERROR_SUCCESS) {
			__time64_t lCurTime;
			_time64( &lCurTime); 
			key.SetDWORDValue(L"pluginlastutc", lCurTime);
			key.Close();
		}
	}
}
开发者ID:fanliaokeji,项目名称:lvdun,代码行数:82,代码来源:AddinHelper.cpp

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

示例15: GenerateErrorReport

void CCrashHandler::GenerateErrorReport(PEXCEPTION_POINTERS pExInfo)
{
   CExceptionReport  rpt(pExInfo);
   CMainDlg          mainDlg;
   CZLib             zlib;
   CString           sTempFileName = CUtility::getTempFileName();
   unsigned int      i;

   // let client add application specific files to report
   if (m_lpfnCallback && !m_lpfnCallback(this))
      return;

	//Определеяем, что делать с отчетом
	DumpType dumpType = Referenced;//По умолчанию сбрасываем только ту память, на которую идут ссылки в стеке
	ActionType actionType = GUI;//По умолчанию - выводим пользователю диалог
	CString action, storeFolder, dump;

	ATL::CRegKey rk;
	//Читаем из ключа с именем приложения
	int32_t lRet = rk.Open(HKEY_LOCAL_MACHINE,
	   TEXT("SOFTWARE\\Cognitive Technologies Ltd.\\CuneiForm\\PumaCrashRpt\\")
	   + CUtility::getAppName(), KEY_QUERY_VALUE);
	if(lRet != ERROR_SUCCESS)
	{
		//Читаем из дефолтного ключа
		lRet = rk.Open(HKEY_LOCAL_MACHINE,
			TEXT("SOFTWARE\\Cognitive Technologies Ltd.\\CuneiForm\\PumaCrashRpt\\Default"),
			KEY_QUERY_VALUE);
	}
	if(lRet == ERROR_SUCCESS)
	{
		//Читаем дейтсвие
		uint32_t dwBufLen = 1000;
		rk.QueryValue(action.GetBuffer(1000), "Action", &dwBufLen);
	    action.ReleaseBuffer(MAX(dwBufLen - 1, 0));

		//Читаем папку для автосохранения
		dwBufLen = 1000;
		rk.QueryValue(storeFolder.GetBuffer(1000), "StoreFolder", &dwBufLen);
	    storeFolder.ReleaseBuffer(MAX(dwBufLen - 1, 0));

		//Читаем тип дампа
		dwBufLen = 1000;
		rk.QueryValue(dump.GetBuffer(1000), "DumpType", &dwBufLen);
	    dump.ReleaseBuffer(MAX(dwBufLen - 1, 0));

		rk.Close();

		if (!action.IsEmpty())
		{
			if (action.CompareNoCase("GUI") == 0)
				actionType = GUI;
			else if (action.CompareNoCase("QuietStore") == 0)
				actionType = QuietStore;
			else if (action.CompareNoCase("NoAction") == 0)
				actionType = NoAction;

		}
		if (!dump.IsEmpty())
		{
			if (dump.CompareNoCase("Mini") == 0)
				dumpType = Mini;
			else if (dump.CompareNoCase("Referenced") == 0)
				dumpType = Referenced;
			else if (dump.CompareNoCase("Full") == 0)
				dumpType = Full;

		}
		if (storeFolder.CompareNoCase("Temp folder") == 0)
			storeFolder = getenv("TEMP");
	}

	if (actionType == NoAction)
		return;

   // add crash files to report
   m_files[rpt.getCrashFile(dumpType)] = CString((const char *)IDS_CRASH_DUMP);
   m_files[rpt.getCrashLog()] = CString((const char *)IDS_CRASH_LOG);

   // add symbol files to report
   for (i = 0; i < (uint)rpt.getNumSymbolFiles(); i++)
      m_files[(const char *)rpt.getSymbolFile(i)] =
      CString((const char *)IDS_SYMBOL_FILE);

   // zip the report
   if (!zlib.Open(sTempFileName))
      return;

   // add report files to zip
   TStrStrMap::iterator cur = m_files.begin();
   for (i = 0; i < m_files.size(); i++, cur++)
      zlib.AddFile((*cur).first);

   zlib.Close();

   if (actionType == GUI)
   {
	   // display main dialog
	   mainDlg.m_pUDFiles = &m_files;

//.........这里部分代码省略.........
开发者ID:PauloMigAlmeida,项目名称:cuneiform,代码行数:101,代码来源:CrashHandler.cpp


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