AbnormalTermination

This function indicates whether the try block of a try-finally statement terminated normally. This function can be called only from within the finally block of a try-finally statement.

At a Glance

Header file: Excpt.h
Windows CE versions: 1.0 and later

Syntax

BOOL AbnormalTermination(void);

Return Values

Nonzero indicates that the try block of the try-finally statement terminated abnormally. Zero indicates that the try block of the try-finally statement terminated normally.

Remarks

The Excpt.h file has to be explicitly included in order to use this function.

The try block terminates normally only if execution leaves the block sequentially after executing the last statement in the block. Statements (such as return, goto, continue, or break) that cause execution to leave the try block result in abnormal termination of the block. This is the case even if such a statement is the last statement in the try block.

Abnormal termination of a try block causes the system to search backward through all stack frames to determine whether any termination handlers must be called. This can result in the execution of hundreds of instructions, so it is important to avoid abnormal termination of a try block due to a return, goto, continue, or break statement. Note that these statements do not generate an exception, even though the termination is abnormal.

To avoid abnormal termination of the try-finally block, execution should continue to the end of the block. You can also execute the leave statement. The leave statement allows for immediate termination of the try block without causing abnormal termination and its performance penalty. Check your compiler documentation to determine if the leave statement is supported.