# sndPlaySound Function

`Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long`

sndPlaySound plays either a .WAV file or a system-defined sound (depending on which flags are set). If the SND_NODEFAULT flag is used, the function returns 0 if the .WAV file (or system sound) cannot be found and 1 if it is. If it is not set, the function always returns 1 and plays the Windows Default sound if the specified sound cannot be found.

lpszSoundName
  Either the path and filename of the .WAV file to play, or the name of the system sound to play.
uFlags
  Zero or more of the sound flags.

Example:

    ' Play the Empty Recycle Bin sound and halt
    '  execution until it is finished playing
    x = sndPlaySound("EmptyRecycleBin", SND_ALIAS Or SND_SYNC)

Category: Audio
Back to the index.