SetErrorMode function
Controls whether the system will handle the specified types of serious errors or whether the process will handle them.
Syntax
UINT WINAPI SetErrorMode( __in UINT uMode );
Parameters
- uMode [in]
-
The process error mode. This parameter can be one or more of the following values.
Return value
The return value is the previous state of the error-mode bit flags.
Remarks
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 the GetErrorMode 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:
SetErrorMode(SEM_NOALIGNMENTFAULTEXCEPT); fuOldErrorMode = SetErrorMode(0); ASSERT(fuOldErrorMode == SEM_NOALIGNMENTFAULTEXCEPT);
Itanium: An application must explicitly call SetErrorMode with SEM_NOALIGNMENTFAULTEXCEPT to have the system automatically fix alignment faults. The default setting is for the system to make alignment faults visible to an application.
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, see Windows Data Alignment.
Windows 7:Callers should favor SetThreadErrorMode over SetErrorMode since it is less disruptive to the normal behavior of the system.
Requirements
|
Minimum supported client | Windows 2000 Professional |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 9/11/2011
public static extern uint SetErrorMode(uint hHandle);
- 8/31/2011
- mhubal
Thanks
1) it is ugly...
2) your app is hung while the dialog is being displayed as the file system call you are making does not return until the user interacts with it.
- 5/11/2010
- Chris_Guzak
This API effects a per process error mode value, making the use of this dangerous for multi-threaded programs. Windows 7 adds new APIs to help manage that.
1) Per thread error mode via GetThreadErrorMode()/SetThreadErrorMode() (http://msdn.microsoft.com/en-us/library/dd553630(VS.85).aspx, http://msdn.microsoft.com/en-us/library/dd553630(VS.85).aspx)
2) the abilit to query the current error mode value so changes to it can be made without clobbering the current value using GetErrorMode() (http://msdn.microsoft.com/en-us/library/ms679355(VS.85).aspx)
- 5/11/2010
- Chris_Guzak
