#include "Stdafx.h" #include "GameServer.h" #include "GameServerDlg.h" #include #pragma comment(lib, "dbghelp.lib") ////////////////////////////////////////////////////////////////////////////////// // 创建Dump文件 // void CreateDumpFile(LPCSTR lpstrDumpFilePathName, EXCEPTION_POINTERS *pException) { // 创建Dump文件; // HANDLE hDumpFile = CreateFile(lpstrDumpFilePathName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); // Dump信息; // MINIDUMP_EXCEPTION_INFORMATION dumpInfo; dumpInfo.ExceptionPointers = pException; dumpInfo.ThreadId = GetCurrentThreadId(); dumpInfo.ClientPointers = TRUE; // 写入Dump文件内容; // MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hDumpFile, MiniDumpNormal, &dumpInfo, NULL, NULL); CloseHandle(hDumpFile); } // 处理Unhandled Exception的回调函数; // LONG ApplicationCrashHandler(EXCEPTION_POINTERS *pException) { char szModulePath[MAX_PATH] = {0}; ::GetModuleFileName(NULL, szModulePath, MAX_PATH); SYSTEMTIME st; ::GetLocalTime(&st); char szFilePath[1024] = {0}; sprintf_s(szFilePath, 1024, "%s%02d%02d%02d%02d%02d.dmp", szModulePath, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond); CreateDumpFile(szFilePath, pException); return EXCEPTION_EXECUTE_HANDLER; } ////////////////////////////////////////////////////////////////////////////////// //程序对象 CGameServerApp theApp; ////////////////////////////////////////////////////////////////////////////////// BEGIN_MESSAGE_MAP(CGameServerApp, CWinApp) END_MESSAGE_MAP() ////////////////////////////////////////////////////////////////////////////////// //构造函数 CGameServerApp::CGameServerApp() { } //启动函数 BOOL CGameServerApp::InitInstance() { // 设置处理Unhandled Exception的回调函数 // SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)ApplicationCrashHandler); __super::InitInstance(); //设置组件 AfxInitRichEdit2(); InitCommonControls(); AfxEnableControlContainer(); //设置注册表 SetRegistryKey(szProduct); //显示窗口 CGameServerDlg GameServerDlg; m_pMainWnd=&GameServerDlg; GameServerDlg.DoModal(); return FALSE; } //////////////////////////////////////////////////////////////////////////////////