This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can trysigning in orchanging directories.
Access to this page requires authorization. You can trychanging directories.
Controls whether the system or the process handles the specified serious error types.
UINT SetErrorMode( [in] UINT uMode);[in] uMode
The process error mode. This parameter can be one or more of the following values.
| Value | Meaning |
|---|---|
| Use the system default, which displays all error dialog boxes. |
| The system does not display the critical-error-handler message box. Instead, the system sends the error to the calling process. Best practice is that all applications call the process-wideSetErrorMode function with a parameter ofSEM_FAILCRITICALERRORS at startup. This is to prevent error mode dialogs from hanging the application. |
| The system automatically fixes memory alignment faults and makes them invisible to the application. It does this for the calling process and any descendant processes. This feature is only supported by certain processor architectures. For more information, see the Remarks section. After this value is set for a process, subsequent attempts to clear the value are ignored. |
| The system does not invoke Windows Error Reporting. To disable Windows Error Reporting UI, call WerSetFlags with the WER_FAULT_REPORTING_NO_UI flag. |
| TheOpenFile function does not display a message box when it fails to find a file. Instead, the error is returned to the caller. This error mode overrides theOF_PROMPT flag. |
The return value is the previous state of the error-mode bit flags.
Each process has an associated error mode that indicates to the system how the application is going to respond to serious errors. A child process inherits the error mode of its parent process. To retrieve the process error mode, use theGetErrorMode function.
Because the error mode is set for the entire process, you must ensure that multi-threaded applications do not set different error-mode flags. Doing so can lead to inconsistent error handling.
The system does not make alignment faults visible to an application on all processor architectures. Therefore, specifying SEM_NOALIGNMENTFAULTEXCEPT is not an error on such architectures, but the system is free to silently ignore the request. This means that code sequences such as the following are not always valid on x86 computers:
| C++ |
|---|
SetErrorMode(SEM_NOALIGNMENTFAULTEXCEPT); fuOldErrorMode = SetErrorMode(0); ASSERT(fuOldErrorMode == SEM_NOALIGNMENTFAULTEXCEPT); |
Visual Studio 2005: When declaring a pointer to a structure that may not have aligned data, you can use the__unaligned keyword to indicate that the type must be read one byte at a time. For more information, seeWindows Data Alignment.
Windows 7: Callers should favorSetThreadErrorMode overSetErrorMode since it is less disruptive to the normal behavior of the system.
| Requirement | Value |
|---|---|
| Minimum supported client | Windows XP [desktop apps | UWP apps] |
| Minimum supported server | Windows Server 2003 [desktop apps | UWP apps] |
| Target Platform | Windows |
| Header | errhandlingapi.h (include Windows.h) |
| Library | Kernel32.lib |
| DLL | Kernel32.dll |
Was this page helpful?
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?
Was this page helpful?
Want to try using Ask Learn to clarify or guide you through this topic?