Microsoft предлагает try {...} except {...}
http://msdn.microsoft.com/ru-ru/library/zazxh1a9.aspxtry-except-statement:
__try compound-statement
__except ( expression ) compound-statement
The compound statement after the __try clause is the guarded section. The compound statement after the __except clause is the exception handler. The handler specifies a set of actions to be taken if an exception is raised during execution of the guarded section. Execution proceeds as follows:
The guarded section is executed.
If no exception occurs during execution of the guarded section, execution continues at the statement after the __except clause.
If an exception occurs during execution of the guarded section or in any routine the guarded section calls, the__except expression is evaluated and the value returned determines how the exception is handled. There are three values:
EXCEPTION_CONTINUE_SEARCH Exception is not recognized. Continue to search up the stack for a handler, first for containing try-except statements, then for handlers with the next highest precedence.
EXCEPTION_CONTINUE_EXECUTION Exception is recognized but dismissed. Continue execution at the point where the exception occurred.
EXCEPTION_EXECUTE_HANDLER Exception is recognized. Transfer control to the exception handler by executing the __except compound statement, then continue execution at the point the exception occurred.
Но except, как я понял, не ловит все исключения а только
The try-except statement is a Microsoft extension to the C language that enables applications to gain control of a program when events that normally terminate execution occur. Such events are called exceptions, and the mechanism that deals with exceptions is called structured exception handling.
потому как в блоке "защищенном" try\except у меня вылетает БСОД, хотя доолжен переходить к except, где исключение обрабатывается.
или я не прав?
Пробовал try {...} catch {...}, который по идее должен ловить все что можно.WDK ругается на catch
error C2061 : syntax error : identifier 'catch'