HOWTO: How To Change Hard Error Popup Handling in Windows NT

This article was previously published under Q128642
SUMMARY
In an unattended environment, you may want to automatically dispatch harderror popups that require user intervention. This article gives you thecode you need to change the hard error popup mode.
MORE INFORMATION
Windows NT allows the user to change the handling of hard error popups thatresult from application and system errors. Such errors include no disk inthe drive and general protection (GP) faults.

Normally, these events cause a hard error popup to be displayed, whichrequires user intervention to dispatch. This behavior can be modified sothat such errors are logged to the Windows NT event log. When the error islogged to the event log, no user intervention is necessary, and the systemprovides a default handler for the hard error. The user can examine theevent log to determine the cause of the hard error.

Registry Entry

The following registry entry controls the hard error popup handling inWindows NT:
   HKEY_LOCAL_MACHINE\     SYSTEM\     CurrentControlSet\     Control\     Windows\     ErrorMode				

Valid Modes

The following are valid values for ErrorMode:
  • Mode 0

    This is the default operating mode that serializes the errors and waits for a response.
  • Mode 1

    If the error does not come from the system, this is the normal operating mode. If the error comes from the system, this logs the error to the event log and returns OK to the hard error. No intervention is required and the popup is not seen.
  • Mode 2

    This always logs the error to the event log and returns OK to the hard error. Popups are not seen.
In all modes, system-originated hard errors are logged to the system log.To run an unattended server, use mode 2.

Sample Code to Change Hard Error Popup Mode

The following function changes the hard error popup mode. If the functionsucceeds, the return value is TRUE. If the function fails, the return valueis FALSE.
BOOL SetGlobalErrorMode(    DWORD dwErrorMode   // specifies new ErrorMode value    ){    HKEY hKey;    LONG lRetCode;    // make sure the value passed isn't out-of-bounds    if (dwErrorMode > 2) return FALSE;    if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,                    "SYSTEM\\CurrentControlSet\\Control\\Windows",                    0,                    KEY_SET_VALUE,                    &hKey) != ERROR_SUCCESS) return FALSE;    lRetCode=RegSetValueEx(hKey,                            "ErrorMode",                            0,                            REG_DWORD,                            (CONST BYTE *) &dwErrorMode,                            sizeof(DWORD) );    RegCloseKey(hKey);    if (lRetCode != ERROR_SUCCESS) return FALSE;    return TRUE;}				

Sample Code to Obtain Hard Error Popup Mode

The following function obtains the hard error popup mode. If the functionsucceeds, the return value is TRUE. If the function fails, the return valueis FALSE. If the function succeeds, dwErrorMode contains the error popupmode. Otherwise, dwErrorMode is undefined.
BOOL GetGlobalErrorMode(    LPDWORD dwErrorMode // Pointer to a DWORD to place popup mode    ){    HKEY hKey;    LONG lRetCode;    DWORD cbData=sizeof(DWORD);    if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,                    "SYSTEM\\CurrentControlSet\\Control\\Windows",                    0,                    KEY_QUERY_VALUE,                    &hKey) != ERROR_SUCCESS) return FALSE;    lRetCode=RegQueryValueEx(hKey,                            "ErrorMode",                            0,                            NULL,                            (LPBYTE) dwErrorMode,                            &cbData );    RegCloseKey(hKey);    if (lRetCode != ERROR_SUCCESS) return FALSE;    return TRUE;}				
3.50
Ιδιότητες

Αναγνωριστικό άρθρου: 128642 - Τελευταία αναθεώρηση: 11/17/2010 20:06:00 - Αναθεώρηση: 4.0

Microsoft Win32 Application Programming Interface, Microsoft Windows 2000 Advanced Server, Microsoft Windows 2000 Enterprise Edition, Microsoft Windows 2000 Standard Edition, Windows Server 2008 R2 Datacenter, Windows Server 2008 R2 Enterprise, Windows Server 2008 R2 Standard, Windows Server 2008 Datacenter, Windows Server 2008 Enterprise, Windows Server 2008 Standard, Windows Vista Business, Windows Vista Enterprise, Windows Vista Home Basic, Windows Vista Home Premium, Windows Vista Ultimate, Windows 7 Enterprise, Windows 7 Home Premium, Windows 7 Professional, Windows 7 Ultimate, Microsoft Exchange Server 2003 Standard Edition, Microsoft Exchange Server 2003 Enterprise Edition

  • kbcode kberrmsg kbhowto kbkernbase KB128642
Σχόλια