SetThreadErrorMode function

Controls whether the system will handle the specified types of serious errors or whether the calling thread will handle them.

Syntax


BOOL SetThreadErrorMode(
  _In_   DWORD dwNewMode,
  _Out_  LPDWORD lpOldMode
);

Parameters

dwNewMode [in]

The thread error mode. This parameter can be one or more of the following values.

ValueMeaning
0

Use the system default, which is to display all error dialog boxes.

SEM_FAILCRITICALERRORS
0x0001

The system does not display the critical-error-handler message box. Instead, the system sends the error to the calling thread.

Best practice is that all applications call the process-wide SetErrorMode function with a parameter of SEM_FAILCRITICALERRORS at startup. This is to prevent error mode dialogs from hanging the application.

SEM_NOGPFAULTERRORBOX
0x0002

The system does not display the Windows Error Reporting dialog.

SEM_NOOPENFILEERRORBOX
0x8000

The system does not display a message box when it fails to find a file. Instead, the error is returned to the calling thread.

 

lpOldMode [out]

If the function succeeds, this parameter is set to the thread's previous error mode. This parameter can be NULL.

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

Each process has an associated error mode that indicates to the system how the application is going to respond to serious errors. A thread inherits the error mode of the process in which it is running. To retrieve the process error mode, use the GetErrorMode function. To retrieve the error mode of the calling thread, use the GetThreadErrorMode function.

Requirements

Minimum supported client

Windows 7 [desktop apps only]

Minimum supported server

Windows Server 2008 R2 [desktop apps only]

Header

WinBase.h (include Windows.h)

Library

Kernel32.lib

DLL

Kernel32.dll

See also

GetThreadErrorMode
SetErrorMode

 

 

Community Additions

ADD
Show:
© 2014 Microsoft