在框架中重载消息WM_QUERYENDSESSION即可在MFC中可以使用BOOL CWnd::OnQueryEndSession();The framework calls this member function when the user chooses to end the Windows session or when an application calls theExitWindows Windows function. If any application returns 0, the Windows session is not ended. Windows stops calling OnQueryEndSession as soon as one application returns 0 and sends the WM_ENDSESSION message with a parameter value of FALSE for any application that has already returned nonzero.

解决方案 »

  1.   

    在框架中重载消息WM_QUERYENDSESSION即可在MFC中可以使用BOOL CWnd::OnQueryEndSession();The framework calls this member function when the user chooses to end the Windows session or when an application calls theExitWindows Windows function. If any application returns 0, the Windows session is not ended. Windows stops calling OnQueryEndSession as soon as one application returns 0 and sends the WM_ENDSESSION message with a parameter value of FALSE for any application that has already returned nonzero.
      

  2.   

    在框架中重载消息WM_QUERYENDSESSION即可在MFC中可以使用BOOL CWnd::OnQueryEndSession();The framework calls this member function when the user chooses to end the Windows session or when an application calls theExitWindows Windows function. If any application returns 0, the Windows session is not ended. Windows stops calling OnQueryEndSession as soon as one application returns 0 and sends the WM_ENDSESSION message with a parameter value of FALSE for any application that has already returned nonzero.
      

  3.   

    这位大哥有没有试过啊我也想到过WM_QUERYENDSESSION,可是它只有在Windows结束的时候才被调用,不信你试试看。
      

  4.   

    响应子窗口的WM_CLOSE,或在mfc中用OnClose.不要用缺省实现,返回一个0就行了。缺省实现会关闭常口
      

  5.   

    好办法!为什么我没有想到!谢谢tiongkohlang