zoukankan      html  css  js  c++  java
  • SetUnhandledExceptionFilter

    SetUnhandledExceptionFilter 设置未捕获异常处理

    通常windows程序长时间运行,会发生各种问题,例如访问异常,内存溢出,堆栈破坏等。

    这时候通常希望程序自己能增加处理,而不是依靠系统弹出错误提示框(灰常不友好).

    //For proc exception 
    LONG WINAPI ExpFilter(struct _EXCEPTION_POINTERS *pExp)  
    {  
        ACE_DEBUG((LM_ERROR, "Exception code : %X, address: %x Exit!
    ",
            pExp->ExceptionRecord->ExceptionCode,
            pExp->ExceptionRecord->ExceptionAddress));
    
        MessageBox(NULL, "Exception", "提示", MB_OK); 
        //::exit(-1);
    
        return EXCEPTION_EXECUTE_HANDLER;  
    } 
    
    //Test exception
    // Exception code c0000374
    //RaiseException(0xc0000374, 0, 0, NULL); // Exception code c0000005 // int* p1 = NULL; // *p1 = 99;

    //For exception in main
    ::SetUnhandledExceptionFilter(ExpFilter);

     

    PS: The RaiseException function raises an exception in the calling thread.

    MSDN中有关SetErrorMode的详细描述,可以这样调用。

    //The system does not display a message box when it fails to find a file. Instead, the error is returned to the calling process.

    SetErrorMode(SEM_NOOPENFILEERRORBOX)

    参考http://blog.csdn.net/woshinia/article/details/10212387

  • 相关阅读:
    ZOJ1542 POJ1861
    Codeforces Round #194 (Div. 2) 部分题解
    SRM585 div2
    hdu 4627 The Unsolvable Problem
    hdu 4622 Reincarnation
    hdu 4617 Weapon
    hdu 4609 3-idiots
    hdu 4616 Game
    hdu 4611 Balls Rearrangement
    hdu 4618 Palindrome Sub-Array
  • 原文地址:https://www.cnblogs.com/iclk/p/3535219.html
Copyright © 2011-2022 走看看