C++軟件添加dump調試打印日記(推舉)。本站提示廣大學習愛好者:(C++軟件添加dump調試打印日記(推舉))文章只能為提供參考,不一定能成為您想要的結果。以下是C++軟件添加dump調試打印日記(推舉)正文
C++軟件添加dump調試打印日記(推舉)
#include <DbgHelp.h> #pragma comment(lib, "dbghelp.lib") LONG WINAPI TopLevelExceptionFilter(struct _EXCEPTION_POINTERS *pExceptionInfo) { //cout << "Enter TopLevelExceptionFilter Function" << endl; TCHAR szPath[MAX_PATH] = { 0 }; TCHAR szFileName[MAX_PATH] = { 0 }; TCHAR* szVersion = "v1.0"; TCHAR dwBufferSize = MAX_PATH; SYSTEMTIME stLocalTime; GetLocalTime(&stLocalTime); CreateDirectory(szFileName, NULL); StringCchPrintf(szFileName, MAX_PATH, "%s-%04d%02d%02d-%02d%02d%02d-%ld-%ld.dmp", szVersion, stLocalTime.wYear, stLocalTime.wMonth, stLocalTime.wDay, stLocalTime.wHour, stLocalTime.wMinute, stLocalTime.wSecond, GetCurrentProcessId(), GetCurrentThreadId()); HANDLE hFile = CreateFile(szFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); MINIDUMP_EXCEPTION_INFORMATION stExceptionParam; stExceptionParam.ThreadId = GetCurrentThreadId(); stExceptionParam.ExceptionPointers = pExceptionInfo; stExceptionParam.ClientPointers = FALSE; MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpWithFullMemory, &stExceptionParam, NULL, NULL); CloseHandle(hFile); getchar(); return EXCEPTION_EXECUTE_HANDLER; } //----------------------------------------------
在法式最開端的處所挪用這個函數
SetUnhandledExceptionFilter(TopLevelExceptionFilter);
以上這篇C++軟件添加dump調試打印日記(推舉)就是小編分享給年夜家的全體內容了,願望能給年夜家一個參考,也願望年夜家多多支撐。