#include <DbgHelp.h>
#pragma comment(lib,"Dbghelp.lib")long __stdcall CrashInfocallback(_EXCEPTION_POINTERS* pexcp)
{// 创建dmp文件HANDLE hDumpFile = ::CreateFile(L"Memory.DMP",GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);if (hDumpFile != INVALID_HANDLE_VALUE){// dmp文件信息MINIDUMP_EXCEPTION_INFORMATION dumpInfo;dumpInfo.ExceptionPointers = pexcp;dumpInfo.ThreadId = GetCurrentThreadId();dumpInfo.ClientPointers = TRUE;// 写入dmp文件内容::MiniDumpWriteDump(GetCurrentProcess(),GetCurrentProcessId(),hDumpFile,MiniDumpNormal,&dumpInfo,NULL,NULL);}return 0;
}int main(int argc, char *argv[])
{::SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)CrashInfocallback);
http://t.csdn.cn/VYw1z
http://t.csdn.cn/SBmVH
http://t.csdn.cn/tT7Fr