PlaySound function

Systems: WinNT (Unicode)
Library/ordinal: WINMM: 10 (Ansi), 11 (Unicode)
(Also exported as 'PlaySound' with ordinal 9!)

STDCALL BOOL PlaySound(LPCSTR pszSound, HMODULE hmod, DWORD fdwSound);

Plays a waveform (digital) sound specified by the given filename, resource, or system event. (A system event may be associated with a sound in the registry or in the WIN.INI file.)

pszSound

A string that specifies the sound to play. Three flags in fdwSound (SND_ALIAS, SND_FILENAME, and SND_RESOURCE) determine whether the name is interpreted as an alias for a system event (in the [Sounds] section of the registry), a filename, or a resource identifier. If an alias is specified and does not exist, the default system sound ("SystemDefault") is played instead, unless SND_NODEFAULT is specified in fdwSound.

The sound specified by pszSound must fit into available physical memory and be playable by an installed waveform-audio device driver. PlaySound searches the following directories for sound files: the current directory; the Windows directory; the Windows system directory; directories listed in the PATH environment variable; and the list of directories mapped in a network. For more information about the directory search order, see the documentation for the OpenFile function.

hmod

Handle of the executable file that contains the resource to be loaded. This parameter must be NULL unless SND_RESOURCE is specified in fdwSound (a resource is to be played).

fdwSound

Flags for playing the sound. The following values are defined:
SND_ALIAS
SND_FILENAME
SND_RESOURCE
Specifies the sound is either an alias for a system event, a filename or a resource name (or number), respectively. Only one of these flags may be specified.
SND_ASYNC
SND_SYNC
Specifies that the sound is to be played asynchronously or synchronoulsy respectively. Asynchronous sounds play while the calling program continues to run.
SND_NOWAITIf the driver is busy, return immediately without playing the sound. Otherwise, wait until the driver is not busy before playing the sound.
With SND_ALIAS:
SND_NODEFAULTSystemDefault sound should not be played if given sound cannot be found.

Contributed by Jose Antonio Noda <jant_noda@redestb.es>