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


C++ CCrashHandler::SetProcessExceptionHandlers方法代码示例

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


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

示例1: InitInstance

BOOL CPeraProcessDesignerApp::InitInstance()
{
	ZTools::InitZToolsLog();

	if ( !m_CmdLine.Parse() )
	{
		MessageBox( NULL, "解析命令行失败!", g_lpszAppTitle, MB_OK | MB_TOPMOST );
		return FALSE;
	}

	m_hMetux = CreateMutex(NULL,TRUE,"PeraProcessDesigner.exe");
	if (m_hMetux)
	{
		if (ERROR_ALREADY_EXISTS== GetLastError())
		{
			HWND hwndPeraProcessDesignerCopied = FindPeraProcessDesignerMainWindow();
			//当有互斥,但是没找到窗口时,认为之前的进程还在启动中,简单处理,直接退出
			if ( hwndPeraProcessDesignerCopied)
			{
				if ( !m_CmdLine.GetValue( NULL ).IsEmpty() )
				{
#define WS_OPENWS_SENDMSG
#ifdef WS_OPENWS_SENDMSG
					DWORD dwProcessId = 0;
					GetWindowThreadProcessId(hwndPeraProcessDesignerCopied, &dwProcessId); 
					if ( GetTopModalWindow( dwProcessId ) == NULL )
					{
						CSharedMemory Mem;
						CString sMemData = g_lpszDoubleOpenWsMemStr;
						Mem.Init( g_lpszDoubleOpenWsMemName, sMemData.GetLength()+MAX_PATH );
						SendCopyData( hwndPeraProcessDesignerCopied, CPMSG_WORKSPACE_MAKESUREINFO, (LPVOID)NULL, 0 );
						sMemData.Empty();
						sMemData = (LPCTSTR)Mem.GetData();
						if ( sMemData.CompareNoCase( g_lpszDoubleOpenWsMemStr ) == 0 )
						{
							MessageBox( NULL, "建模环境处于活动状态,请先保存模型后重试!", g_lpszAppTitle, MB_OK | MB_TOPMOST );
						}
						else
						{
							CString sCmdLine = ::GetCommandLine();
							SendCopyData( hwndPeraProcessDesignerCopied, CPMSG_WORKSPACE_OPENWS, (LPVOID)(LPCTSTR)sCmdLine, sCmdLine.GetLength()+1 );
						}
					}
					else
					{
						MessageBox( NULL, "建模环境处于活动状态,请先保存模型后重试!", g_lpszAppTitle, MB_OK | MB_TOPMOST );
					}
#else
					MessageBox( hwndPeraProcessDesignerCopied, "建模环境已打开,请在建模环境中打开本文件!", g_lpszAppTitle, MB_OK | MB_TOPMOST );
#endif
				}
				if (IsIconic(hwndPeraProcessDesignerCopied)) 
					ShowWindow(hwndPeraProcessDesignerCopied,SW_RESTORE);

				SetForegroundWindow(hwndPeraProcessDesignerCopied);
				ZTools::WriteZToolsFormatLog("将已经运行的建模窗口激活,并前端显示...");

			}
			CloseHandle(m_hMetux);
			m_hMetux = NULL;
			ZTools::WriteZToolsFormatLog("已经存在一个建模客户端,本运行实例将退出...");

			return FALSE;
		}
	}

	m_LoginData.m_strRealName = m_CmdLine.GetValue( "realName" );
	m_LoginData.m_strUser = m_CmdLine.GetValue( "userName" );
	m_LoginData.m_strTicket = m_CmdLine.GetValue( "ticket-proxy" );

	WriteShareMemoryLoginInfo();

	CCrashHandler ch;
	ch.SetProcessExceptionHandlers();
	ch.SetThreadExceptionHandlers();

	//如果PeraTaskService进程不存在,自动启动
	StartPeraTaskService();

	//_CrtSetBreakAlloc(1300);
	// InitCommonControlsEx() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	INITCOMMONCONTROLSEX InitCtrls;
	InitCtrls.dwSize = sizeof(InitCtrls);
	// Set this to include all the common control classes you want to use
	// in your application.
	InitCtrls.dwICC = ICC_WIN95_CLASSES;
	InitCommonControlsEx(&InitCtrls);

	//hModule = ::LoadLibrary("C:\\Users\\kunmiao-li\\Desktop\\TestBuild\\PeraLicMgr\\Release\\PeraLicMgr.dll");
//#ifndef _DEBUG

	if (!InitLicense("PeraWorkSpace"))
		return FALSE;
// 	if(!m_FlexNetMgr.CheckOutLicense("PeraWorkSpace"))
// 	{
// 		return FALSE;
// 	}

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

示例2: InitInstance

BOOL CFileManagerApp::InitInstance()
{
	// InitCommonControls() is required on Windows XP if an application
	// manifest specifies use of ComCtl32.dll version 6 or later to enable
	// visual styles.  Otherwise, any window creation will fail.
	InitCommonControls();

	CWinApp::InitInstance();
#if CONSOLE_WND
	InitConsoleWindow();
#endif

	AfxEnableControlContainer();
	LogTools::InitZToolsLog();
	CCrashHandler ch;
	ch.SetProcessExceptionHandlers();
	ch.SetThreadExceptionHandlers();

	globalData.SetDPIAware ();
	ProcessCmd();
	HANDLE hMetux = CreateMutex(NULL,TRUE,"FileManager_Sqlite3");
	if (hMetux)
	{
		if(ERROR_ALREADY_EXISTS==GetLastError())
		{
			CloseHandle(hMetux);
			CWnd * pDeskTopWnd = CWnd::GetDesktopWindow();
			CWnd *pFind = pDeskTopWnd->GetWindow(GW_CHILD);
			while(pFind)
			{
				if (::GetProp(pFind->m_hWnd,m_pszExeName))
				{
					if (::IsIconic(pFind->m_hWnd))
						pFind->ShowWindow(SW_RESTORE); // 如果主窗口已经最小话,则恢复其大小
					pFind->ShowWindow(SW_SHOW);
					pFind->SetForegroundWindow();
					::SetForegroundWindow(::GetLastActivePopup(pFind->m_hWnd));
					return FALSE; // 前一个运行实例已经存在,退出本实例
				}
				pFind = pFind->GetWindow(GW_HWNDNEXT);
			}
		}
	}

	CFileManagerDlg dlg;
	dlg.m_bRunAtBack = m_bRunAtBack;
	m_pMainWnd = &dlg;
	INT_PTR nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
	}

	BCGCBProCleanUp ();
	CloseHandle(hMetux);
	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}
开发者ID:cugxiangzhenwei,项目名称:MySrcCode,代码行数:65,代码来源:FileManager.cpp


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