?????????? EXCEPTEX MFC ? Win32 ???? ?????????

?????? ????????? ?????? ?????????
???? ???????: 167802 - ??? ???????? ???? ????? ????? ??? ???????.
??? ????? ??? ???????. ????? "??? ??" ??? ??? ??????? ??? ????.
????? ???? | ?? ????

?? ??? ??????

??????

?? EXCEPTEX ???? ???? ??? ????? ?? ?? ?? ????????? ???????? Win32 ? ????????? C++ ??????. ?? C++ ????????? ??????? ???????? ??? ????? ????? ????? ??????? ??? ???? ????? ??????? ?????? ?????????. ????????? ???????? Win32 ???? ????? ???? ???? ????? ??? ??? ??????? Win32.

??????? ??????? ??? ?????? ??????? ?? "???? ??????? ?? Microsoft":


Exceptex.exe

?????? ??? ??????? ?????? ??? ????? ????? ????? ??? Microsoft "? ???? ??? ??? ??????? ?????? ?????? ??" ????? ??????? ?? Microsoft:
119591????? ?????? ??? ????? ??? Microsoft ?? ??????? ??? ????????
???? Microsoft ???? ??? ????? ????? ?? ?????????. ??????? Microsoft ???? ?? ?????? ??? ??????? ??????? ??? ??????? ???? ?? ??? ?????. ??? ????? ????? ??? ?????? ????? ?????? ???? ????? ??? ??? ????? ??? ??????? ??? ???? ??? ??? ?????.

??????? ????

??? Win32 ? ?????? ??????? C++

?????? ??????? C++ ?????? ??????? ???????? ?? Win32 ?????? ???? ?????? ?????? ??? ?????? ???????????.
    // C++ Exception Handler
    try
    {
        // Do something that may raise an exception
    }
    catch( <class name> <instance of class> )
    {
        // handle exception
    }

    // Win32 Structured Exception Handler
    __try
    {
        // Do something that may raise an exception
    }
    __except( expression )
    {
        // handle exception
    }
				
????? fundamental API ?? ????? ?????? ????????? C++ ???? ???? ?? ??? ? ????? ?????? ??????? ???????? ?? Win32 catches ??? ????? ??? ????? ????.

?????, ??? ????? ?? ???? ??? ?? ?? "C++" ? "?????? ?????? ?????? _set_se_translator() ??????? Win32. ???? ??? ??????? Win32 ??? ???? ????? ?? ??????? ????? ???? ?????? ??????? ??????? Win32 ?? ??? "???" ???? ??? C++ ?????????. ????? ??? ???????? ??? ??????? Win32 ????? ???? ????? ??? ???????? ?? ??????? C++ (???? "???????? ?????? ???????" ?? infoviewer 5.0 VC). ??? ?? ????? ???????? ??? ??? ?????? ????? ??????? ??? ???????? ??? ????? ????? ????? Log().
    // Class for containing information on a Win32 Structured Exception
    class SEH_Exception {
    private:
        SEH_Exception() {}
        unsigned int m_uSECode;
    public:
        SEH_Exception(unsigned int uSECode) : m_uSECode(uSECode) {}
        ~SEH_Exception() {}
        unsigned int getSeHNumber() { return m_uSECode; }
    };

    // Handler function that passes on Win32 Exception information in the
    // C++ class SEH_Exception
    void MappingSEHtoCPPExceptions( unsigned int uExceptionCode,
                                                  _EXCEPTION_POINTERS* )
    {
        throw SEH_Exception( uExceptionCode );
    }

    // Initialize Exception Handling
    void LogEnable( ... )
    {
        // Set Win32 Exceptions to be handled as C++ typed exceptions
        _set_se_translator(MappingSEHtoCPPExceptions);

        ...
    }
				
?? ??? ??????? LogEnable ?? ???? ??????? ??? ????? ? ?????? ?? ????? ???????? ? ??? ????????? Win32 ????? ?? ?? ???? ?? ??? ???????? ???? ?????? C++. EXCEPTEX ???? ??????? ??? ???????? ??????? ?????? ????? ?????.

????? ????????? C++

???? ??? ???? ?? ????????? C++ ???? ?? ???? ?? ??? ?????? ?????? ????? ??? MFC:

  • ?????? ?????? ??????? ?? ????? ?? MFC CException
  • ?????? ????? ????? Win32 ???????
  • ?????? ?? _com_error ??? ???? ??? ??? ?????? 5.0 Visual C++ ???? COM ??????? ?????? ?????? ????? #import.
??? ?? ??? ???? EXCEPTEX ??????? LogException ?????? ??? ?????? ?? ??? ???? ?? ?????? ??????? ????. ?? ?? ???? ??? ??????? ???? ?? ???? ?? ??? ???? ??? C++ ?????. ???? ??????? LogException over-loaded ??? ?? ????? ??????? C++ ???????? ?????.

???? ?? ???? ????? ?????? LogException overloaded catches ???? ??? ??? CException MFC.
    // Crack open and log details of different types of exceptions
    extern void LogException( CException    *e,
                              LPCSTR        lpszTimeStamp,
                              LPCSTR        lpszFile,
                              int           nLine        );
				
LogException ????? ????? ??? ??? ???? ????? ??? ?? ??????? ????? ????????? ?????? ?? ???? ??????????? (??? ???? ??????? ????? ??? ???????).

?? ?? ??????? ??? ??????? ??? ???? ????????? ????? ??????? ?? ???? ????? ???? ?????? ???????. ?? ???? ????? ??????? ??? ???? ??????? ??? ??????? TRACE() LogDisplay().

????? ????/catch ???? ????? ??? "????? ????? ?????"

littering ??? ????/catch ?? ????????? ???????? ???? ?????? ??? messy ??? ?????. ??? ???? ?? ?????? ????? ????????? ??? ???? ??????? ????? ???????. ???? EXCEPTEX ???? ????? ??????? ?????? ??? ??????? ??? ?? ???? ????? ?????? ?????/?????? ???????????. ??? ????? ?? ?? ????? ??????? ????? ????? ??? 4.X Visual C++ ? 5.0 Visual C++ ? ??? ????? ??? ?????? ?? ????? ?????? ??????? ??????? ???? ???????.

???? ????? ???? ????? ??????? LOGQ (?????? "??????? ????????" ?? ?? ?????). ????? ?? ????? ????? ?????? ???? bRetVal ?? ????????? ????????. ??? ?? ???? ?????? ???? ???? ??????? ????? ????????? ???????? ???? ?? ???? ?????? ??????? ?? ???? ?????? ??? FALSE ?? ???? ???????.
    #if _MSC_VER < 1100    // For version VC++ 4.2 or earlier

        #define LOGQ( f ) if( bRetVal == TRUE )                \ 
                          {                                    \ 
                             try                               \ 
                             {                                 \ 
                                 f;                            \ 
                             }                                 \ 
                             catch( CException *e )            \ 
                             {                                 \ 
                                bRetVal = FALSE;               \ 
                                 e->Delete();                  \ 
                             }                                 \ 
                             catch( SEH_Exception )            \ 
                             {                                 \ 
                                bRetVal = FALSE;               \ 
                             }                                 \ 
                             catch(...)                        \ 
                             {                                 \ 
                                bRetVal = FALSE;               \ 
                             }                                 \ 
                          }

    #else

        #define LOGQ( f ) if( bRetVal == TRUE )                \ 
                          {                                    \ 
                             try                               \ 
                             {                                 \ 
                                f;                             \ 
                             }                                 \ 
                             catch( CException *e )            \ 
                             {                                 \ 
                                bRetVal = FALSE;               \ 
                                e->Delete();                   \ 
                             }                                 \ 
                             catch( _com_error )               \ 
                             {                                 \ 
                                bRetVal = FALSE;               \ 
                              }                                \ 
                             catch( SEH_Exception )            \ 
                             {                                 \ 
                                bRetVal = FALSE;               \ 
                             }                                 \ 
                             catch(...)                        \ 
                             {                                 \ 
                                bRetVal = FALSE;               \ 
                             }                                 \ 
                          }

    #endif
				
_MSC_VER #ifdef ?????? ????? ????? ????? 4.X Visual C++ ?? 5.0. ????? ??????? 5.0 catch ??????? _com_error ??????? ?????? (?? ?????? ?????? ????????? ???????? ???? ?? ??????? ?? #import).

??????? LOGQ ??? ?? ???? ?????:
    int     i = 0;
    int     j;
    BOOL    bRetVal = TRUE;

    // This code is not safe
    j = 1 / i;        // Raises Win32 Divide By Zero exception

    // This code is safe
    LOGQ( j = 1 / i; )
				
???? ????? ??????? ???? ?? ????? ??????? ??? ?????? EXCEPTEX. ?????? ??????? ??? ?????? ????????? LogException() overloaded ??????? ?????.
    #define LOGE( f ) try                               \ 
                      {                                 \ 
                          f;                            \ 
                      }                                 \ 
                      catch( CException *e )            \ 
                      {                                 \ 
                          LogException( e,              \ 
                                        __TIMESTAMP__,  \ 
                                        __FILE__,       \ 
                                        __LINE__      );\ 
                      }                                 \ 
                      ...
				
??? ??????? ?? ???? ??????? ?? bRetVal ???????. ???? ???? ????? ????? ????????? ???????? ????? ?????? ??????? ? ?????? ?? ????????? ????? ?????? ?????????.

???? ??????? ??? ???????? ???????? ?? ??? EXCEPTEX LOGR ? ?? LOGQ ? LOGE. ?????? ?????? ?? ??? ??? ??? ????? ????????? ???????? ?????? ?? ??????? ????.
    #define LOGR( f ) if( bRetVal == TRUE )                 \ 
                      {                                     \ 
                          try                               \ 
                          {                                 \ 
                              f;                            \ 
                          }                                 \ 
                          catch( CException *e )            \ 
                          {                                 \ 
                              LogException( e,              \ 
                                            __TIMESTAMP__,  \ 
                                            __FILE__,       \ 
                                            __LINE__      );\ 
                              bRetVal = FALSE;              \ 
                          }                                 \ 
                          ...
                        }
				

??????? ?????? ???????

???? ???? EXCEPTEX ????? ?????? ?? ??????? ??????? ?????? ?????????:
LogDisplay() ????? ??????? ???? ??????????? ????? ?????? ???? TRACE ????? ???????.

LogDisplay (...) ????? ??????? ???? ??????????? ????? ?????? ??? ???? CListBox.

LogSaveToFile (...) ????? ??????? ???? ??????????? ????? ?????? ??? ???.

LOG.H ? LOG.CPP

LOG.H ? LOG.CPP ????? ??? ???? ????????? ???????? ?? EXCEPTEX ??????? ???????????. ????? ??????? ??????? ??? ??? ????? ?????/??????? ?? LOG.H ? LOG.CPP. ??? ??????? ???? ????? ?????? ??? ????? ????? ??? ????? ??????? ??????? ?? ??? 4.X Visual C++ ?? ???? 5.0 ??? ?? ?? ANSI ? UNICODE. ???????? ??? ????? # ????? "log.h" ??? ??????? ???? ??????? ??????? LOGE ?? LOGR. ??? ??? ???? ??????? ????????? ???????? Win32 ????? ??? ??????? LogEnable ??? ????? ?????? ?? ????? ???????? ????? ??.
   // One time initialization of data
    LogEnable(false);     // false to verbose mode
				
????? ??????? ??? ?? ????????? ???????? ???? ???? ??????? ?? ?????? ??? ????????.
   ...
   LOGE(myFunction())
   ...
				
?????? ???????? ?? ????? ???? ??? ???? ??????? ??? ??? ?? ???? ????? ???????. ??? ?????? myFunction() myFun1() ? myFun2() ? ??? ?????? ?? ??????? ?????? ?? ????? ??? ??????? ???? ??????? ?? ??? ????????? ??.

?? ?? ???? ????? ??????? ??? ?? ????? ????? ?? ??? LogException() ????????? ??? ?? ??????. ??? ??? ?????? ?? ???????? ?? ??? ???? ??? ??? ?????? ????????? ????? ? ?????? ????? ?? ??????? ??????. ?? ??? ????? ??? ?? end-all ???? ???? ??????? ?????? ?? ?? ???? ?????.

??????? ??????? ????????

???? ???????? ???????? ??????? ??? ??? ??????? ????? ??????? ???????
    LOGQ( int i = 0; )
    LOGQ( int j = 1 / i; )    // Will this raise a divide by zero?
				
?????? ??? ????? ??? ?????? ??????? ????? ??? ??? ?????? i ??? ?? ???? ??????? LOGQ ?????. ???? ????? LOGQ ???:
>
    ...
    try
    {
        int i = 0;
    }
    ...

    ...
    try
    {
        int j = 1 / i;  // error C2065: 'i' : undeclared
    }
    ...
				

/ W4 ? #import

?? ???? ??????? ????? /W4 ?? Visual C++ ? #import ?????? 8 ????????? ???? ?? ??????? ????? ????? ??????? ???? ?????? #import.
comutil.h(905): ????? C4310: ????? ?????? ???? ?????
comutil.h(928): ????? C4310: ????? ?????? ???? ?????
comutil.h(1030): ????? C4310: ????? ?????? ???? ?????
comutil.h(1281): ????? C4310: ????? ?????? ???? ?????
comutil.h(1307): ????? C4310: ????? ?????? ???? ?????
comutil.h(1476): ????? C4310: ????? ?????? ???? ?????
comdef.h(242): ????? C4244: '?????': ??????? ?? 'Int' ??? ' ????' ? ?????? ????? ????????
???? ????? ????? ????? ??? ? ??? ?? ?? ???? ??? ????????? ???????? ?????? ??.

?????? ??? ???? ?? ?????????

????? ??????? infoviewer VC ++ 5.0 ?????? ????? ???? ??? ?????? ?????? ?????????:
?????? ?????????: ??????? ?????????
mk:@ivt:vccore/F26/D2A/S31BE4.HTM

???????? ?????? ?????????
mk:@ivt:vccore/F26/D2B/S4CC99.HTM
???? ??????? ??????? ???????? ???? ???? ????????? ?????? ????? EXCEPTEX ??????? ??????????? SDK DAO.
152695????? ?????? ?? DAO ???????? ??? SDK ?????????
???? ?????? ??? ???? definitive ??? ?????? ??????? Win32 ??:

"Windows ????????" ?????? Richter ????? ISBN 1-57231-548-2

???????

???? ???????: 167802 - ????? ??? ??????: 14/???? ??????/1435 - ??????: 3.2
????? ???
  • Microsoft Visual C++ 4.2 Enterprise Edition
  • Microsoft Visual C++ 5.0 Enterprise Edition
  • Microsoft Visual C++ 4.0 Standard Edition
  • Microsoft Visual C++ 4.1 Subscription
  • Microsoft Visual C++ 4.2 Professional Edition
  • Microsoft Visual C++ 5.0 Professional Edition
????? ??????: 
kbnosurvey kbarchive kbmt kbdownload kbdatabase kbfile kbsample KB167802 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????167802

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com