Highlights
All Snippets
Top 100 Snippets
Librarians
gbCodeLib

By Language
VB6
JavaScript
Perl
HTML
SQL
Java
DOS

GBIC >> Source Code >> Visual Basic >> Snippet

Play sound (API only)


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

'set the filename of the sound to be played
SoundFile = "sound.wav"

'play sound once (in the background)
iReturn = sndPlaySound(SoundFile, &H1)

'play sound once (programs waits until done)
iReturn = sndPlaySound(SoundFile, &H0)

'play sound continuously
iReturn = sndPlaySound(SoundFile, &H8)

'stop sound once it has started
iReturn = sndPlaySound(vbNullString, False )