Compartilhar via


Enabling Default Reply

User32 provides the functionality to intercept every MessageBox function and automatically choose the default button. Not all message box windows are produced through the standard MessageBox function; therefore, this feature might not operate on all windows.

To instruct NTUSER to intercept messages, an additional key and values are required in the HKLM\System\CurrentControlSet\Control registry key. You might need to create the registry key and values on your system, as follows.

To set up your system to automatically reply to a message box without displaying it

  1. In the HKLM\System\CurrentControlSet\Control registry key, create a new key named Error Message Instrument.
  2. Under the Error Message Instrument key, add the values of type REG_DWORD from the following table.
    Value Data Description
    EnableDefaultReply 0x00000001 Enables the Enable Default Reply feature.
    EnableLogging 0x00000001 Enables event logging.
  3. Under the Error Message Instrument registry key, add one of the LogSeverity values of type REG_DWORD from the following table.
    Value Data Description
    LogSeverity 0x00000000 = EMI_SEVERITY_ALL All message box events are logged.
    LogSeverity 0x00000001 = EMI_SEVERITY_USER Message box events with the dwStyle parameter defined are logged, including MB_USERICON, MB_ICONASTERISK, MB_ICONQUESTION, MB_ICONEXCLAMATION, and MB_ICONHAND.
    LogSeverity 0x00000002 = EMI_SEVERITY_INFORMATION Errors, warnings, questions, and information are logged. Message box events with no dwStyle parameter or dwStyle = MB_ICONUSER are not logged.
    LogSeverity 0x00000003 = EMI_SEVERITY_QUESTION Errors, warnings, and questions are logged. Information, events with no style, and user-defined severity levels are not logged.
    LogSeverity 0x00000004 = EMI_SEVERITY_WARNING Only errors and warnings are logged.
    LogSeverity 0x00000005 = EMI_SEVERITY_ERROR. (EMI_SEVERITY_MAX_VALUE) Only errors are logged.

To log message information to the event log

  1. In the HKLM\System\CurrentControlSet\Services\EventLog\Application registry key, create a new key named Error Instrument.
  2. Under the Error Instrument key, add the registry values from the following table.
    Value Type Value
    TypesSupported REG_DWORD 0x00000007
    EventMessageFile REG_EXPAND_SZ %SystemRoot%\System32\User32.dll

You must reboot your target system for the changes to take effect.

See Also

Message Box and Balloon Pop-Up Interception

Last updated on Wednesday, October 18, 2006

© 2006 Microsoft Corporation. All rights reserved.