Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

The PlaySoundfunction also plays sounds that are referred to by a key name in the registry. Using this capability, you can let users assign selected or custom sounds to system alerts and warnings. Sounds that are associated with system alerts and warnings are called sound events.

To play a sound event
  • Call PlaySound, and set the pszSoundparameter so that pzSoundpoints to a string that contains the name of the registry entry that identifies the sound.

    The following code example shows how to use PlaySoundto play a sound event.

    Copy Code
    PlaySound (TEXT("MouseClick"), NULL, SND_SYNC);
    
    Note:
    PlaySoundplays the default system sound if the registry entry that is specified in pszSounddoes not exist, or if the sound file cannot be stored in available device memory.

The sndPlaySoundfunction searches the registry for a key name that matches the lpszSoundNameparameter, before sndPlaySoundattempts to load a file that has a file name that matches lpszSoundName. The PlaySoundfunction accepts flags that specify the location of the sound.

See Also