Книга: Microsoft Windows Embedded CE 6.0 Exam Preparation Kit

Exception Handler Syntax

Exception Handler Syntax

Windows Embedded CE supports frame-based structured exception handling. It is possible to enclose a sensitive sequence of code in braces ({}) and mark it with the __try keyword to indicate that any exceptions during the execution of this code should invoke an exception handler that follows in a section marked by using the __except keyword. The C/C++ compiler included in Microsoft Visual Studio supports these keywords and compiles the code blocks with additional instructions that enable the system either to restore the machine state and continue thread execution at the point at which the exception occurred, or to transfer control to an exception handler and continue thread execution in the call stack frame in which the exception handler is located.

The following code fragment illustrates how to use the __try and __except keywords for structured exception handling:

__try {
 // Place guarded code here.
} __except (filter-expression) {
 // Place exception-handler code here.
}

The __except keyword supports a filter expression, which can be a simple expression or a filter function. The filter expression can evaluate to one of the following values:

EXCEPTION_CONTINUE_EXECUTION The system assumes that the exception is resolved and continues thread execution at the point at which the exception occurred. Filter functions typically return this value after handling the exception to continue processing as normal.

EXCEPTION_CONTINUE_SEARCH The system continues its search for an appropriate exception handler.

EXCEPTION_EXECUTE_HANDLER The system thread execution continues sequentially from the exception handler rather than from the point of the exception.

NOTE

Exception handling support

Exception handling is an extension of the C language, but it is natively supported in C+ + .

Оглавление книги


Генерация: 1.716. Запросов К БД/Cache: 3 / 0
поделиться
Вверх Вниз