本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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));
}
}