标签:
SetErrorMode() 函数控制 Windows 是否处理 指定类型的严重错误或使调用应用程序来处理它们。
#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