The SetErrorMode function controls whether the system will handle the specified types of serious errors, or whether the process will handle them.
UINT SetErrorMode(
UINT uMode // bit flags specifying the process error mode
);
Value | Action |
---|---|
SEM_FAILCRITICALERRORS | The system does not display the critical-error-handler message box. Instead, the system sends the error to the calling process. |
SEM_NOALIGNMENTFAULTEXCEPT | RISC only: 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 flag has no effect on x86 processors. |
SEM_NOGPFAULTERRORBOX | The system does not display the general-protection-fault message box. This flag should only be set by debugging applications that handle general protection (GP) faults themselves with an exception handler. |
SEM_NOOPENFILEERRORBOX | The system does not display a message box when it fails to find a file. Instead, the error is returned to the calling process. |
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.
RISC only: On some non-x86 processors misaligned memory references cause an alignment fault exception. The SEM_NOALIGNMENTFAULTEXCEPT flag lets you control whether the system automatically fixes such alignment faults, or makes them visible to an application.
MIPS only: On a MIPS computer, an application must explicitly call SetErrorMode with the SEM_NOALIGNMENTFAULTEXCEPT flag to have the system automatically fix alignment faults. The default setting is for the system to make alignment faults visible to an application.
Alpha only: On an ALPHA computer, you control the alignment fault behavior by setting the EnableAlignmentFaultExceptions value in the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager registry key as follows:
Value | Meaning |
---|---|
0 | Automatically fix alignment faults. This is the default. |
1 | Make alignment faults visible to the application. You must call SetErrorMode with SEM_NOALIGNMENTFAULTEXCEPT to have the system automatically fix alignment faults. |
2 | Windows NT 5.0 and later: Alignment faults are visible only when the process is running under the debugger. |
x86 only: On an x86 computer, the system does not make alignment faults visible to an application. Therefore, specifying the SEM_NOALIGNMENTFAULTEXCEPT flag on an x86 computer is not an error, but the system is free to silently ignore and not properly preserve the flag. This means that code sequences such as the following are not always valid on x86 computers:
SetErrorMode(SEM_NOALIGNMENTFAULTEXCEPT);
fuOldErrorMode = SetErrorMode(0);
ASSERT(fuOldErrorMode == SEM_NOALIGNMENTFAULTEXCEPT);
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in winbase.h.
Import Library: Use kernel32.lib.
Errors Overview, Error Functions