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


C++ CHandle::Close方法代码示例

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


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

示例1: update_final

        void worker::update_final(CHandle& _mutex)
        {
            progress_ = 5;
            emit progress(progress_);

            run_async_function(copy_files_from_updates, [this, &_mutex](const installer::error& _err)
            {
                if (!_err.is_ok())
                {
                    emit error(_err);
                    return;
                }

                run_async_function(write_to_uninstall_key, [this, &_mutex](const installer::error& _err)
                {
                    if (!_err.is_ok())
                    {
                        emit error(_err);
                        return;
                    }

                    _mutex.Close();

                    run_async_function(start_process, [this](const installer::error& _err)
                    {
                        if (!_err.is_ok())
                        {
                            emit error(_err);
                            return;
                        }

                        run_async_function(copy_self_from_updates, [this](const installer::error& _err)
                        {
                            if (!_err.is_ok())
                            {
                                emit error(_err);
                                return;
                            }

                            run_async_function(delete_updates, [this](const installer::error& _err)
                            {
                                if (!_err.is_ok())
                                {
                                    emit error(_err);
                                    return;
                                }

                                emit finish();

                            }, 100);
                        }, 90);
                    }, 80);
                }, 75);
            }, 70);
        }
开发者ID:4ynyky,项目名称:icqdesktop,代码行数:55,代码来源:worker.cpp

示例2: CloseProgressWindow

 void CloseProgressWindow(bool cancel = false)
 {
     if (!m_progressWindowThread)
         return;
     Sleep(100); // It could be that m_pProgressDlg->DoModal not yet created a window
     if (m_progressWindow)
         m_progressWindow->PostMessage(WM_CLOSE);
     WaitForSingleObject(m_progressWindowThread, INFINITE);
     m_progressWindowThread.Close();
     if (!cancel)
         g_cancel = false;
 }
开发者ID:15375514460,项目名称:TortoiseGit,代码行数:12,代码来源:CrashProcessor.cpp

示例3: writeHandleAndInject

//----------------------------------------------------------------------------
// writeHandleAndInject
//  Writes the internal mIEMainWindow to the mem file and invokes the page
//  action broker to inject the page actions DLL into the IE process.
HRESULT Proxy::writeHandleAndInject(DWORD aProcessId)
{
  // detect bitness of target process
  CHandle process(::OpenProcess(  PROCESS_QUERY_LIMITED_INFORMATION, FALSE, aProcessId ));
  if( !process ) {
    return HRESULT_FROM_WIN32(::GetLastError());
  }
  BOOL is64 = Is64bitProcess(process);
  process.Close();

  // write window handle
  CHandle fileMapping;
  HRESULT hr = writeHandle(mIEMainWindow, fileMapping.m_h);
  if (FAILED(hr)) {
    return hr;
  }

  // prepare broker process
  STARTUPINFO startInfo;
  ::ZeroMemory( &startInfo, sizeof( startInfo ) );
  startInfo.cb = sizeof( startInfo );
  startInfo.dwFlags |= STARTF_USESHOWWINDOW;
  startInfo.wShowWindow = FALSE;

  PROCESS_INFORMATION processInfo;
  ::ZeroMemory( &processInfo, sizeof( processInfo ) );

  // pass process-ID
  CString params;
  params.Format(_T("%lu"), aProcessId);

  // path for broker exe to use
  CString path;
  path.Format(_T("%s%s"), (is64) ? mInstallPath64 : mInstallPath32, sBrokerExec);

  if( ::CreateProcess(
      path.GetBuffer(MAX_PATH), params.GetBuffer(MAX_PATH),
      NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL,
      &startInfo, &processInfo ) ){
    ::WaitForSingleObject( processInfo.hProcess, INFINITE );
    ::CloseHandle( processInfo.hThread );
    ::CloseHandle( processInfo.hProcess );
    return S_OK;
  }
  // something went wrong. Call GetLastError BEFORE closing file handle!
  DWORD dw = ::GetLastError();
  fileMapping.Close();
  return HRESULT_FROM_WIN32(dw);
}
开发者ID:digital-carver,项目名称:ancho,代码行数:53,代码来源:PageActionProxy.cpp

示例4: CloseHFProcess

void CHFServer::CloseHFProcess(LPCSTR szProcessName)
{
	std::string sProcessName =  utils::upcase(std::string(szProcessName));
	DWORD dwID = 0;
	CHandle hProcess = GetProcessId(sProcessName, dwID);
	long iCount = 0;
	if(hProcess == NULL)
		EgLib::CEgLibTraceManager::Trace(LogFaults, __FUNCTION__ , _T("No %s module found"), sProcessName.c_str());	

	while( hProcess != NULL)
	{
		EgLib::CEgLibTraceManager::Trace(LogFaults, __FUNCTION__ , _T("Terminating %s module"), sProcessName.c_str());	
		

		if(!TerminateProcess(hProcess, 0)  )
		{
			DWORD dwError = GetLastError();

			if(dwID)
			{
				if(!Kill(dwID))
					EgLib::CEgLibTraceManager::Trace(LogFaults, __FUNCTION__ , _T("Kill Process %s Failed with error %d and terminate with error %d"), sProcessName.c_str(), GetLastError() , dwError);	
			}  
			else
				EgLib::CEgLibTraceManager::Trace(LogFaults, __FUNCTION__ , _T("Unable to terminate %s module %d"), sProcessName.c_str(), dwError);	
		}

		if(++iCount > 10)
		{
			EgLib::CEgLibTraceManager::Trace(LogFaults, __FUNCTION__ , _T("Too many %s process to terminate %d"), sProcessName.c_str(), GetLastError());	
			break;
		}
		hProcess.Close();
		hProcess.Attach(GetProcessId(sProcessName, dwID));
	}
}
开发者ID:AlexS2172,项目名称:IVRM,代码行数:36,代码来源:hfserver.cpp


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