void __cdecl CCrashHandler::PureCallHandler() { // Pure virtual function call CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { // Fill in the exception info CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_CPP_PURE_CALL; pCrashHandler->GenerateErrorReport(&ei); } // Terminate program exit(1); }
void cpp_sigint_handler(int) { // Interruption (SIGINT) CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { // Fill in the exception info CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_CPP_SIGINT; pCrashHandler->GenerateErrorReport(&ei); } // Terminate program exit(1); }
// CRT terminate() call handler void __cdecl CCrashHandler::TerminateHandler() { // Abnormal program termination (terminate() function was called) CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { // Fill in the exception info CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_CPP_TERMINATE_CALL; pCrashHandler->GenerateErrorReport(&ei); } // Terminate program exit(1); }
// CRT SIGTERM signal handler void CCrashHandler::SigtermHandler(int) { // Termination request (SIGTERM) CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { // Fill in the exception info CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_CPP_SIGTERM; pCrashHandler->GenerateErrorReport(&ei); } // Terminate program exit(1); }
crInstallToCurrentThread2(DWORD dwFlags) { crSetErrorMsg(_T("Success.")); CCrashHandler *pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); if(pCrashHandler==NULL) { // AS: Correction of error message crSetErrorMsg(_T("Crash handler not installed for this process.")); return 1; } int nResult = pCrashHandler->SetThreadExceptionHandlers(dwFlags); if(nResult!=0) return 2; // Error? // Ok. return 0; }
// CRT unexpected() call handler void __cdecl CCrashHandler::UnexpectedHandler() { // Unexpected error (unexpected() function was called) CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { // Fill in the exception info CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_CPP_UNEXPECTED_CALL; pCrashHandler->GenerateErrorReport(&ei); } // Terminate program exit(1); }
crUninstallFromCurrentThread() { crSetErrorMsg(_T("Success.")); CCrashHandler *pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); if(pCrashHandler==NULL) { ATLASSERT(pCrashHandler!=NULL); crSetErrorMsg(_T("Crash handler wasn't previously installed for current thread.")); return 1; // Invalid parameter? } int nResult = pCrashHandler->UnSetThreadExceptionHandlers(); if(nResult!=0) return 2; // Error? // OK. return 0; }
// CRT sigill signal handler void CCrashHandler::SigillHandler(int) { // Illegal instruction (SIGILL) CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { // Fill in the exception info CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_CPP_SIGILL; pCrashHandler->GenerateErrorReport(&ei); } // Terminate program ExitProcess(1); }
crAddVideo( DWORD dwFlags, int nDuration, int nFrameInterval, SIZE* pDesiredFrameSize, HWND hWndParent ) { crSetErrorMsg(_T("Unspecified error.")); CCrashHandler *pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); if(pCrashHandler==NULL) { crSetErrorMsg(_T("Crash handler wasn't previously installed for current process.")); return 1; // Invalid parameter? } return pCrashHandler->AddVideo(dwFlags, nDuration, nFrameInterval, pDesiredFrameSize, hWndParent); }
// CRT SIGABRT signal handler void CCrashHandler::SigabrtHandler(int) { // Caught SIGABRT C++ signal CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { // Fill in the exception info CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_CPP_SIGABRT; pCrashHandler->GenerateErrorReport(&ei); } // Terminate program exit(1); }
int __cdecl CCrashHandler::NewHandler(size_t) { // 'new' operator memory allocation exception CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { // Fill in the exception info CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_CPP_NEW_OPERATOR_ERROR; ei.pexcptrs = NULL; pCrashHandler->GenerateErrorReport(&ei); } exit(1); // Terminate program }
void cpp_sigsegv_handler(int) { // Invalid storage access (SIGSEGV) CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { // Fill in exception info CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_CPP_SIGSEGV; ei.pexcptrs = (PEXCEPTION_POINTERS)_pxcptinfoptrs; pCrashHandler->GenerateErrorReport(&ei); } // Terminate program exit(1); }
crSetCrashCallbackA( PFNCRASHCALLBACKA pfnCallbackFunc, LPVOID lpParam ) { crSetErrorMsg(_T("Unspecified error.")); CCrashHandler *pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); if(pCrashHandler==NULL) { crSetErrorMsg(_T("Crash handler wasn't previously installed for current process.")); return 1; // No handler installed for current process? } pCrashHandler->SetCrashCallbackA(pfnCallbackFunc, lpParam); // OK crSetErrorMsg(_T("Success.")); return 0; }
LONG WINAPI Win32UnhandledExceptionFilter(PEXCEPTION_POINTERS pExceptionPtrs) { CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_WIN32_STRUCTURED_EXCEPTION; ei.pexcptrs = pExceptionPtrs; pCrashHandler->GenerateErrorReport(&ei); } // Terminate program exit(1); #if _MSC_VER<1300 // This is to make MSVC6.0 compiler happy return EXCEPTION_EXECUTE_HANDLER; #endif }
void __cdecl cpp_security_handler(int code, void *x) { // Security error (buffer overrun). code; x; CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { // Fill in the exception info CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_CPP_SECURITY_ERROR; pCrashHandler->GenerateErrorReport(&ei); } exit(1); // Terminate program }
void cpp_sigfpe_handler(int /*code*/, int subcode) { // Floating point exception (SIGFPE) CCrashHandler* pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); ATLASSERT(pCrashHandler!=NULL); if(pCrashHandler!=NULL) { // Fill in the exception info CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_CPP_SIGFPE; ei.pexcptrs = (PEXCEPTION_POINTERS)_pxcptinfoptrs; ei.fpe_subcode = subcode; pCrashHandler->GenerateErrorReport(&ei); } // Terminate program exit(1); }
crExceptionFilter(unsigned int code, struct _EXCEPTION_POINTERS* ep) { crSetErrorMsg(_T("Unspecified error.")); CCrashHandler *pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); if(pCrashHandler==NULL) { crSetErrorMsg(_T("Crash handler wasn't previously installed for current process.")); return EXCEPTION_CONTINUE_SEARCH; } #ifdef CRASHRPT_EX // AS: Unless the user will indeed check for the user choice this makes no real // sense here. // We assume that the execute_handler does what it should -> close the app. pCrashHandler ->AllowContinue(0); #endif CR_EXCEPTION_INFO ei; memset(&ei, 0, sizeof(CR_EXCEPTION_INFO)); ei.cb = sizeof(CR_EXCEPTION_INFO); ei.exctype = CR_SEH_EXCEPTION; ei.pexcptrs = ep; ei.code = code; int res = pCrashHandler->GenerateErrorReport(&ei); if(res!=0) { // If goes here than GenerateErrorReport() failed return EXCEPTION_CONTINUE_SEARCH; } crSetErrorMsg(_T("Success.")); return EXCEPTION_EXECUTE_HANDLER; }
CRASHRPTAPI(int) crUninstall() { crSetErrorMsg(_T("Success.")); // Get crash handler singleton CCrashHandler *pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); // Check if found if(pCrashHandler==NULL || !pCrashHandler->IsInitialized()) { crSetErrorMsg(_T("Crash handler wasn't preiviously installed for this process.")); return 1; } // Uninstall main thread's C++ exception handlers int nUnset = pCrashHandler->UnSetThreadExceptionHandlers(); if(nUnset!=0) return 2; // Destroy the crash handler. int nDestroy = pCrashHandler->Destroy(); if(nDestroy!=0) return 3; // Free the crash handler object. delete pCrashHandler; // Clear last error message list. g_cs.Lock(); g_sErrorMsg.clear(); g_cs.Unlock(); return 0; }
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; // } // hModule = ::LoadLibrary(ZTools::FormatString("%s\\PeraLicMgr.dll", GetFlexwareBinPathMethod()).c_str()); // if( hModule != NULL ) // { // lpFnDLLfunc = (LPFNDLLFUNC) ::GetProcAddress(hModule, "CheckOutLicense"); // if(lpFnDLLfunc != NULL) // { // if(!lpFnDLLfunc("PeraProcessDesigner")) // { // return FALSE; // } // } // else // { // return FALSE; // } // } // else // { // AfxMessageBox("检测到系统安装不完整,请联系管理员重新安装!", MB_OK|MB_ICONINFORMATION); // return FALSE; // } //#endif //if(!m_FlexNetMgr.InitNewJob("PeraProcessDesigner")) //{ // return FALSE; //} CWinApp::InitInstance(); InitGDIPlus(); LoadResLibImageSet(); //LoadDefaultFont(); //CBCGPPopupMenuBar::SetPeraPaint( g_crToolbarBg ); //CXmlBase xml; //MSXML2::IXMLDOMDocument2Ptr pdoc = xml.GetXmlDocPtrByFile(GetExecDir() + "\\Manifest.xml"); //MSXML2::IXMLDOMNodeListPtr pModels; //MSXML2::IXMLDOMNodePtr pModel; //long lModelCount; //HRESULT hr = S_OK; //map<CString, CString> mapAttrs; //map<CString, CString>::iterator iterAttrs; //CString str; //pModels = xml.GetNodeListPtr("/Manifest/Component", pdoc); //if (pModels != NULL) //{ // lModelCount = pModels->Getlength(); // for (long i=0; i<lModelCount; i++) // { // hr = pModels->get_item(i, &pModel); // if (FAILED(hr) || NULL == pModel) // { // continue; // } // if (0 == xml.GetAttrsOfNode(mapAttrs, pModel)) // { // continue; // } // iterAttrs = mapAttrs.find("RobotName"); // if (iterAttrs != mapAttrs.end()) str= iterAttrs->second; // } //} //CCxArray3D a3d(DT_ARRAY3D_INT); //CString str3d = "[1,2,3,4,5,](4,3,2)" //CString str = "[1e150,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24](2,3,4)"; // CString str = "[\"\\\\\\\",,1e150\",\"2\"](2)"; //{ // CString str1; // for (int a=0;a<2;a++) // { // for (int b=0;b<3;b++) // { // for (int c=0;c<4;c++) // { // } // } // } //} // //CxArrayND nd( DT_ARRAY1D_STRING ); //nd.Parse( str ); //vector<int> vPos; //vPos.push_back(0); ////vPos.push_back(0); ////vPos.push_back(0); //LPARAM lpData = nd.GetDataPtr( vPos ); //CString * pData = reinterpret_cast< CString * > ( lpData ); //nd.Clear(); // Initialize OLE libraries if (!AfxOleInit()) { AfxMessageBox(IDP_OLE_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); EnableTaskBarInteraction(FALSE); globalData.SetDPIAware (); //globalData.bDisableAero = TRUE; //Bar挺靠后,Slider宽度,由于Splitter最小宽度为4,所以此值不应小于4,否则与Splitter不协调。 CBCGPSlider::m_nDefaultWidth = 4; // All registry read/write operations will be produced via CBCGPXMLSettings gateway: CBCGPRegistrySP::SetRuntimeClass (RUNTIME_CLASS (CBCGPXMLSettings)); // Read settings: CBCGPXMLSettings::ReadXMLFromFile (FALSE, GetExecDir() + _T("\\user.xml")); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need // Change the registry key under which our settings are stored // TODO: You should modify this string to be something appropriate // such as the name of your company or organization //SetRegistryKey(_T("PeraProcessDesigner")); //LoadStdProfileSettings(0); // Load standard INI file options (including MRU) //SetRegistryBase (_T("Settings")); RECT rectDesktop; SystemParametersInfo(SPI_GETWORKAREA,0,(PVOID)&rectDesktop,0); m_rcLastWindowPlacement = rectDesktop; CRect rectDesktop2 = rectDesktop; int nFlag = 0; int nShowCmd = 0; LoadWindowPlacement( m_rcLastWindowPlacement, nFlag, nShowCmd ); StoreWindowPlacement (rectDesktop2, 2, SW_SHOWMAXIMIZED); theGlobalConfig.Load(); m_bAloneVersionWs = IsPeraProcessRunnerInstalled(); CCxBCGPVisualManager2007::SetStyle (CCxBCGPVisualManager2007::VS2007_Silver); CCxBCGPVisualManager2007::SetDefaultManager (RUNTIME_CLASS (CCxBCGPVisualManager2007)); //globalData.bDisableAero = TRUE; //globalData.bIsOSAlphaBlendingSupport = TRUE; // Initialize all Managers for usage. They are automatically constructed // if not yet present InitMouseManager(); //InitContextMenuManager(); InitKeyboardManager(); // Enable user-defined tools. If you want allow more than 10 tools, // add tools entry to resources (ID_USER_TOOL11, ID_USER_TOOL12,...) EnableUserTools (ID_TOOLS_ENTRY, ID_USER_TOOL1, ID_USER_TOOL10); // TODO: Remove this if you don't want extended tooltips: InitTooltipManager(); CBCGPToolTipParams params; params.m_bVislManagerTheme = TRUE; theApp.GetTooltipManager ()->SetTooltipParams ( BCGP_TOOLTIP_TYPE_ALL, RUNTIME_CLASS (CBCGPToolTipCtrl), ¶ms); // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views CMultiDocTemplate* pDocTemplate; pDocTemplate = new CMultiDocTemplate(IDR_MAIN, RUNTIME_CLASS(CPeraProcessDesignerDoc), RUNTIME_CLASS(CChildFrame), // custom MDI child frame RUNTIME_CLASS(CPeraProcessDesignerView)); if (!pDocTemplate) return FALSE; AddDocTemplate(pDocTemplate); // create main MDI Frame window CMainFrame* pMainFrame = new CMainFrame; if (!pMainFrame->LoadFrame(IDR_MAIN)) return FALSE; m_bCreate = TRUE; m_pMainWnd = pMainFrame; //basehtmldialog中,屏蔽快捷键 g_hwndMainWindow = pMainFrame->GetSafeHwnd(); g_pLoadingWindow = new CLoadingWindow( TIMER_LOADING_WINDOW, IDD_DIALOG_LOGIN_BK, m_pMainWnd ); g_pLoadingWindow->Create( IDD_DIALOG_LOGIN_BK, m_pMainWnd ); g_pLoadingWindow->Init( GetExecDir() + "\\Res\\DlgProgress\\DlgProgress.png" ); pMainFrame->m_wndMenuBar.LoadData(); //pMainFrame->OnMenuModuleOpenjianmo(); // call DragAcceptFiles only if there's a suffix // In an MDI app, this should occur immediately after setting m_pMainWnd // Parse command line for standard shell commands, DDE, file open //CCommandLineInfo cmdInfo; //ParseCommandLine(cmdInfo); //if (cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew) //{ // if (!pMainFrame->LoadMDIState (GetRegSectionPath ()) || // DYNAMIC_DOWNCAST(CMDIChildWnd, pMainFrame->GetActiveFrame()) == NULL) // { // if (!ProcessShellCommand(cmdInfo)) // return FALSE; // } //} //else //{ // // Dispatch commands specified on the command line // if (!ProcessShellCommand(cmdInfo)) // return FALSE; //} // The main window has been initialized, so show and update it pMainFrame->OnMenuModuleOpenjianmo(); m_bInitMDI = TRUE; m_nCmdShow = SW_SHOWMAXIMIZED; pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); ////////////////////////////////////////////////////////////////////////// //日志输出窗口 #ifdef USE_DLGLOG m_dlgLog.Create(CDlgLog::IDD, NULL); //m_dlgLog.ShowWindow(SW_SHOW); // int x, y; // x = GetSystemMetrics(SM_CXFULLSCREEN); //屏幕宽度 // y = GetSystemMetrics(SM_CYFULLSCREEN); //屏幕高度 CRect rectFull; SystemParametersInfo(SPI_GETWORKAREA,0,&rectFull,0); CRect rect; m_dlgLog.GetWindowRect(rect); rect.MoveToXY(0, rectFull.bottom - rect.Height()); m_dlgLog.MoveWindow(rect); #endif // USE_DLGLOG ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// //延长票据有效期 StartKeepTicketThread(); ////////////////////////////////////////////////////////////////////////// //在线编辑用到的共享内存初始化 m_pSharedMemoryOnlineEdit = NULL; m_pSharedMemoryOnlineEdit = new SharedMemoryOnlineEdit(); ////////////////////////////////////////////////////////////////////////// g_ReadRobotDB.Load(); pMainFrame->m_wndLoginBar.RedrawWindow(); CString sParamFile = m_CmdLine.GetValue( NULL ); if ( !sParamFile.IsEmpty() ) { ZTools::WriteZToolsFormatLog( "--------------********打开文件[%s]**********-------------", sParamFile ); theApp.m_processMgr.Open( sParamFile ); } else { ZTools::WriteZToolsLog( "--------------********未打开文件逻辑**********-------------" ); CDlgStart lgn; lgn.DoModal(); } #ifdef USE_DLGLOG m_dlgLog.ShowWindow(SW_SHOW); #endif // USE_DLGLOG ////////////////////////////////////////////////////////////////////////// WINDOWPLACEMENT wp; memset(&wp, NULL, sizeof(wp)); wp.length = sizeof (WINDOWPLACEMENT); if (pMainFrame->GetWindowPlacement (&wp)) { wp.rcNormalPosition = m_rcLastWindowPlacement; RECT rectDesktop; SystemParametersInfo(SPI_GETWORKAREA,0,(PVOID)&rectDesktop,0); OffsetRect(&wp.rcNormalPosition, -rectDesktop.left, -rectDesktop.top); pMainFrame->SetWindowPlacement (&wp); } return TRUE; }
CRASHRPTAPI(int) crInstallW(CR_INSTALL_INFOW* pInfo) { int nStatus = -1; crSetErrorMsg(_T("Success.")); strconv_t strconv; CCrashHandler *pCrashHandler = NULL; // Validate input parameters. if(pInfo==NULL || pInfo->cb!=sizeof(CR_INSTALL_INFOW)) { crSetErrorMsg(_T("pInfo is NULL or pInfo->cb member is not valid.")); nStatus = 1; goto cleanup; } // Check if crInstall() already was called for current process. pCrashHandler = CCrashHandler::GetCurrentProcessCrashHandler(); if(pCrashHandler!=NULL && pCrashHandler->IsInitialized()) { crSetErrorMsg(_T("Can't install crash handler to the same process twice.")); nStatus = 2; goto cleanup; } if(pCrashHandler==NULL) { pCrashHandler = new CCrashHandler(); if(pCrashHandler==NULL) { crSetErrorMsg(_T("Error allocating memory for crash handler.")); nStatus = 3; goto cleanup; } } LPCTSTR ptszAppName = strconv.w2t((LPWSTR)pInfo->pszAppName); LPCTSTR ptszAppVersion = strconv.w2t((LPWSTR)pInfo->pszAppVersion); LPCTSTR ptszCrashSenderPath = strconv.w2t((LPWSTR)pInfo->pszCrashSenderPath); LPCTSTR ptszEmailTo = strconv.w2t((LPWSTR)pInfo->pszEmailTo); LPCTSTR ptszEmailSubject = strconv.w2t((LPWSTR)pInfo->pszEmailSubject); LPCTSTR ptszUrl = strconv.w2t((LPWSTR)pInfo->pszUrl); LPCTSTR ptszPrivacyPolicyURL = strconv.w2t((LPWSTR)pInfo->pszPrivacyPolicyURL); LPCTSTR ptszDebugHelpDLL_file = strconv.w2t((LPWSTR)pInfo->pszDebugHelpDLL); MINIDUMP_TYPE miniDumpType = pInfo->uMiniDumpType; LPCTSTR ptszErrorReportSaveDir = strconv.w2t((LPWSTR)pInfo->pszErrorReportSaveDir); LPCTSTR ptszRestartCmdLine = strconv.w2t((LPWSTR)pInfo->pszRestartCmdLine); LPCTSTR ptszLangFilePath = strconv.w2t((LPWSTR)pInfo->pszLangFilePath); LPCTSTR ptszEmailText = strconv.w2t((LPWSTR)pInfo->pszEmailText); LPCTSTR ptszSmtpProxy = strconv.w2t((LPWSTR)pInfo->pszSmtpProxy); int nInitResult = pCrashHandler->Init( ptszAppName, ptszAppVersion, ptszCrashSenderPath, pInfo->pfnCrashCallback, ptszEmailTo, ptszEmailSubject, ptszUrl, &pInfo->uPriorities, pInfo->dwFlags, ptszPrivacyPolicyURL, ptszDebugHelpDLL_file, miniDumpType, ptszErrorReportSaveDir, ptszRestartCmdLine, ptszLangFilePath, ptszEmailText, ptszSmtpProxy ); if(nInitResult!=0) { nStatus = 4; goto cleanup; } // OK. nStatus = 0; cleanup: if(nStatus!=0) // If failed { if(pCrashHandler!=NULL && !pCrashHandler->IsInitialized()) { // Release crash handler object CCrashHandler::ReleaseCurrentProcessCrashHandler(); } } return nStatus; }
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; }
CRASHRPTAPI void DisableHandlerEx(LPVOID lpState) { CCrashHandler *pImpl = (CCrashHandler*)lpState; CRASH_ASSERT(pImpl); pImpl->DisableHandler(); }
CRASHRPTAPI void EnableUIEx(LPVOID lpState) { CCrashHandler *pImpl = (CCrashHandler*)lpState; CRASH_ASSERT(pImpl); pImpl->EnableUI(); }