79.2.3 Playing System Alert Sounds

If you are familiar with programming for the Windows environment, you should recognize the MessageBeep function. Windows 3.1 replaces the Windows 3.0 MessageBeep function with a function that uses the waveform audio hardware to produce a variety of user-selectable sounds. The new MessageBeep function has the following syntax:

void MessageBeep(wAlert)

The syntax of MessageBeep remains the same, except its previously unused parameter is now used. The wAlert parameter is a UINT and specifies the alert level. Valid flags for wAlert are the same as those passed to MessageBox: MB_ICONASTERISK, MB_ICONEXCLAMATION, MB_ICONHAND, and MB_ICONQUESTION.

When you call the MessageBeep function, it searches the [sounds] section of the WIN.INI file for the WAVE file that corresponds to the specified alert level. The following table identifies the WIN.INI entries for system-alert sounds:

WIN.INI Entry Description
SystemDefault Identifies the sound produced when MessageBeep is called with wAlert set to an invalid alert level or when the requested alert sound can't be found. This is called the default system sound.
SystemAsterisk Identifies the sound produced when MessageBeep is called with wAlert set to MB_ICONASTERISK.
SystemExclamation Identifies the sound produced when MessageBeep is called with wAlert set to MB_ICONEXCLAMATION.
SystemHand Identifies the sound produced when MessageBeep is called with wAlert set to MB_ICONHAND.
SystemQuestion Identifies the sound produced when MessageBeep is called with wAlert set to MB_ICONQUESTION.

If MessageBeep is called with wAlert set to zero, it plays the default system sound. If wAlert is set to -1, it uses the computer speaker to produce a standard beep sound. If MessageBeep can't play the requested sound, it plays the default system sound. If it can't play the default system sound, then it produces a beep sound using the computer speaker.

The Sound option of the Control Panel allows users to set these WIN.INI entries to customize their environment for system-alert sounds. It also allows users to disable these alert sounds.