#include <Dbghelp.h>#include <stdio.h>#include <time.h>#pragma comment(lib,"Dbghelp.lib")LONG WINAPI ExpFilter(struct _EXCEPTION_POINTERS *pExp){time_t now;time(&now);char name[100] = { 0 };sprintf_s(name, "%d.dmp", now);HANDLE hFile = CreateFileA( name,GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);if (INVALID_HANDLE_VALUE != hFile){MINIDUMP_EXCEPTION_INFORMATION einfo;einfo.ThreadId = ::GetCurrentThreadId();einfo.ExceptionPointers = pExp;einfo.ClientPointers = FALSE;::MiniDumpWriteDump(::GetCurrentProcess(),::GetCurrentProcessId(),hFile,MiniDumpWithFullMemory,&einfo,NULL,NULL);::CloseHandle(hFile);}return EXCEPTION_EXECUTE_HANDLER;}long __stdcall ExpFilter1(_EXCEPTION_POINTERS* excp){char buf[1024] = { 0 };sprintf_s(buf, "ExceptionAddress %x \n NumberParameters %x \n ExceptionCode %x \n",excp->ExceptionRecord->ExceptionAddress, excp->ExceptionRecord->NumberParameters, excp->ExceptionRecord->ExceptionCode);MessageBox(0, buf, "error", MB_OK);return EXCEPTION_EXECUTE_HANDLER;}
原文:http://www.cnblogs.com/wxf101/p/4810150.html