Partager via


Using PlaySound with Registry-Specified Sounds

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

The PlaySound function 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 pszSound parameter so that pzSound points to a string that contains the name of the registry entry that identifies the sound.

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

    PlaySound (TEXT("MouseClick"), NULL, SND_SYNC);
    

    Note

    PlaySound plays the default system sound if the registry entry that is specified in pszSound does not exist, or if the sound file cannot be stored in available device memory.

The sndPlaySound function searches the registry for a key name that matches the lpszSoundName parameter, before sndPlaySound attempts to load a file that has a file name that matches lpszSoundName. The PlaySound function accepts flags that specify the location of the sound.

See Also

Concepts

Using the PlaySound Function