次の方法で共有


Error Handling and Notification

For more information on error handling and notification, see Understanding the Helper Function.

If your program uses delay-loaded DLLs, it must handle errors robustly since failures will occur while the program is running, before any user code gets executed. Failure handling is comprised of two portions:

Recovery through a hook.

If your code needs to recover or provide an alternate library and/or routine on failure, a hook can be provided to the helper function that can supply or remedy the situation. The hook routine needs to return a suitable value, so that processing can continue (an HINSTANCE or FARPROC) or 0 to indicate that an exception should be thrown. It could also throw its own exception or longjmp out of the hook. There are notification hooks and failure hooks.

Reporting via an exception.

If all that is necessary for handling the error is to abort the procedure, no hook is necessary as long as the user code can handle the exception.

The following sections discuss error handling and notification: