123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- // PZMedical2121Z.cpp : Defines the class behaviors for the application.
- //
- #include "stdafx.h"
- #include "PZMedical2121Z.h"
- #include "PZMedical2121ZDlg.h"
- #ifndef _DEBUG
- #include ".\\AutoDmp\\AutoDmp.h"
- #endif
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #endif
- //////////////////////////////
- #include <windows.h>
- #include <Dbghelp.h>
- #pragma comment( lib, "DbgHelp" )
- //////////////////////////////
- CString strAppPath;
- extern CString strAppDYNHandleName;
- extern CString strAppMechCompHandleName;
- extern CString strAppRFDTHandleName;
- extern CString strAppDRDTHandleName;
- extern CString strAppHardwareHandleName;
- extern CString strAppRFOCHandleName;
- // PZMedical2121ZApp
- BEGIN_MESSAGE_MAP(PZMedical2121ZApp, CWinApp)
- ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
- END_MESSAGE_MAP()
- // PZMedical2121ZApp construction
- PZMedical2121ZApp::PZMedical2121ZApp()
- {
- // support Restart Manager
- m_dwRestartManagerSupportFlags = AFX_RESTART_MANAGER_SUPPORT_RESTART;
- // TODO: add construction code here,
- // Place all significant initialization in InitInstance
- }
- // The one and only PZMedical2121ZApp object
- PZMedical2121ZApp theApp;
- // PZMedical2121ZApp initialization
- LONG WINAPI UEFilter(PEXCEPTION_POINTERS ExceptionInfo)
- {
- CString strFileName, strTime;
- CTime tm = CTime::GetCurrentTime();
- SYSTEMTIME st;
- GetSystemTime(&st);
- strTime.Format("%04d%02d%02d.%02d%02d%02d%03d", tm.GetYear(), tm.GetMonth(), tm.GetDay(), tm.GetHour(), tm.GetMinute(), tm.GetSecond(), st.wMilliseconds);//modify by zhenglh 20130710
- strFileName = strAppPath + "\\log\\PZMedical2121Z." + strTime + ".dmp";
- HANDLE lhDumpFile = CreateFile(strFileName.GetBuffer(), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
- MINIDUMP_EXCEPTION_INFORMATION loExceptionInfo;
- loExceptionInfo.ExceptionPointers = ExceptionInfo;
- loExceptionInfo.ThreadId = GetCurrentThreadId();
- loExceptionInfo.ClientPointers = TRUE;
- MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), lhDumpFile, MiniDumpNormal, &loExceptionInfo, NULL, NULL);
- CloseHandle(lhDumpFile);
- return EXCEPTION_CONTINUE_SEARCH;
- }
- bool PZMedical2121ZApp::GetLastInstance()
- {
- HANDLE hSem=CreateSemaphore(NULL,1,1,m_pszExeName);
- if(GetLastError() == ERROR_ALREADY_EXISTS)
- {
- CloseHandle(hSem);
- HWND hWndPrevious = ::GetWindow(::GetDesktopWindow(), GW_CHILD);
- while (::IsWindow(hWndPrevious))
- {
- // if the window has our tag?
- if (::GetProp(hWndPrevious, m_pszExeName))
- {
- if (::IsIconic(hWndPrevious))
- ::ShowWindow(hWndPrevious, SW_RESTORE);
- ::SetForegroundWindow(hWndPrevious);
- ::SetForegroundWindow(::GetLastActivePopup(hWndPrevious));
- return FALSE;
- }
- // continue find next window
- hWndPrevious = ::GetWindow(hWndPrevious, GW_HWNDNEXT);
- }
- // the previous instance is exist, but can not be found
- // something wrong?
- return FALSE;
- }
- return true;
- }
- BOOL PZMedical2121ZApp::InitInstance()
- {
- // 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);
- CWinApp::InitInstance();
- if(!GetLastInstance())
- return false;
- GetAppPath();
- ::SetUnhandledExceptionFilter(UEFilter); //20170922 zhangfeng
- #ifndef _DEBUG
- AutoDmp atdmp;
- #endif
- SetPriorityClass(GetCurrentProcess(),REALTIME_PRIORITY_CLASS);
- AfxEnableControlContainer();
- // Create the shell manager, in case the dialog contains
- // any shell tree view or shell list view controls.
- CShellManager *pShellManager = new CShellManager;
- // 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("Local AppWizard-Generated Applications"));
- CPZMedical2121ZDlg dlg;
- 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
- }
- // Delete the shell manager created above.
- if (pShellManager != NULL)
- {
- delete pShellManager;
- }
- // Since the dialog has been closed, return FALSE so that we exit the
- // application, rather than start the application's message pump.
- return FALSE;
- }
- bool PZMedical2121ZApp::GetAppPath()
- {
- TCHAR FullPath[MAX_PATH];
- strAppPath = "";
- GetModuleFileName(NULL , FullPath, MAX_PATH);
- strAppPath.Format("%s" , FullPath);
- int nPos = 1;
- int nBackUpPos = 0;
- while (nPos > 0) {
- nPos = strAppPath.Find("\\", nPos + 1);
- if (nPos > 0)
- {
- nBackUpPos = nPos ;
- }
- }
- strAppPath = strAppPath.Left(nBackUpPos);
- return true;
- }
|