SetErrorMode

2.x

  UINT SetErrorMode(fuErrorMode)    
  UINT fuErrorMode; /* specifies the error-mode flag */

The SetErrorMode function controls whether Windows handles MS-DOS Interrupt 24h errors or allows the calling application to handle them.

Parameters

fuErrorMode

Specifies the error-mode flag. The flag can be a combination of the following values:

Value Meaning

SEM_FAILCRITICALERRORS Windows does not display the critical-error-handler message box and returns the error to the calling application.
SEM_NOGPFAULTERRORBOX Windows does not display the general-protection-fault message box. This flag should be set only by debugging applications that handle GP faults themselves.
SEM_NOOPENFILEERRORBOX Windows does not display a message box when it fails to find a file.

Return Value

The return value is the previous state of the error-mode flag, if the function is successful.

Example

The following example uses the SetErrorMode function to turn off the file-not-found message box (the application handles this error itself):

/* Turn off the "File not found" error box. */

SetErrorMode(SEM_NOOPENFILEERRORBOX);

/* Load the TOOLHELP.DLL library module. */

hinstToolHelp = LoadLibrary("TOOLHELP.DLL");

if (hinstToolHelp > HINSTANCE_ERROR) {    /* loaded successfully */

    .
    . /* Use the DLL here. */
    .

}





else {
    strcpy(szBuf, "LoadLibrary failed");
}

MessageBox(NULL, szBuf, "Library Functions", MB_ICONHAND);