有的程序是有守护进程的,但是由于会发生异常,弹出了异常错误的系统框,导致程序不能继续重启,
在查看windows核心编程的时候注意到了SetErrMode 和 SetUnhandledExceptionFilter (可以自己配置如何处理异常)
下面给出例子:
long __stdcall MyExcpCallback(_EXCEPTION_POINTERS* e)
{
//MessageBox(0,L"Error",L"error",MB_OK);
printf("Error address %x/n",excp->ExceptionRecord->ExceptionAddress);
printf("CPU register:/n");
printf("eax %x ebx %x ecx %x edx %x/n",excp->ContextRecord->Eax,
excp->ContextRecord->Ebx,excp->ContextRecord->Ecx,
excp->ContextRecord->Edx);
return EXCEPTION_EXECUTE_HANDLER;
}
int _tmain(int argc, _TCHAR* argv[])
{
//SetErrorMode(SEM_FAILCRITICALERRORS);
SetUnhandledExceptionFilter(MyExcpCallback);
// 让它异常 ,,,咳咳
return 0;
}