Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function raises an exception in the calling thread.

Syntax

void RaiseException(
  DWORD 
dwExceptionCode,
  DWORD 
dwExceptionFlags,
  DWORD 
nNumberOfArguments,
  const DWORD* 
lpArguments
);

Parameters

dwExceptionCode

[in] The application-defined exception code of the exception being raised. The filter expression and exception-handler block of an exception handler can use the GetExceptionCodefunction to retrieve this value.

The system clears bit 28 of dwExceptionCode. This bit is a reserved exception bit, used by the system for its own purposes.

For example, after calling the RaiseExceptionfunction with a dwExceptionCodevalue of 0xFFFFFFFF, the system displays a message indicating that the exception number is 0xEFFFFFFF.

dwExceptionFlags

[in] The exception flags. This can be either zero to indicate a continuable exception, or EXCEPTION_NONCONTINUABLE to indicate a noncontinuable exception. Any attempt to continue execution after a noncontinuable exception causes the EXCEPTION_NONCONTINUABLE_EXCEPTION exception.

nNumberOfArguments

[in] The number of arguments in the lpArgumentsarray. This value must not exceed EXCEPTION_MAXIMUM_PARAMETERS. This parameter is ignored if lpArgumentsis NULL.

lpArguments

[in] Long pointer to an array of 32-bit arguments. This parameter can be NULL. These arguments can contain any application-defined data that needs to be passed to the filter expression of the exception handler.

Return Value

None.

Remarks

The RaiseExceptionfunction enables a process to use structured exception handling to handle private, software-generated, application-defined exceptions.

The following list shows the exception dispatcher's search process for an exception handler after raising an exception:

  1. The system attempts to notify the process's debugger, if applicable.

  2. If the process is not being debugged, or if the associated debugger does not handle the exception, the system attempts to locate a frame-based exception handler by searching the stack frames of the thread in which the exception occurred.

    The system searches the current stack frame first; then it proceeds backward through preceding stack frames.

  3. If no frame-based handler can be found, or no frame-based handler handles the exception, the system makes a second attempt to notify the process's debugger.

  4. If the process is not being debugged, or if the associated debugger does not handle the exception, the system provides default handling based on the exception type.

The values specified in the dwExceptionCode, dwExceptionFlags, nNumberOfArguments, and lpArgumentsparameters can be retrieved in the filter expression of a try- exceptframe-based exception handler by calling the GetExceptionInformationfunction.

A debugger can retrieve these values by calling the WaitForDebugEventfunction.

Requirements

Header winbase.h
Library coredll.lib
Windows Embedded CE Windows CE 1.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also