Attribute VB_Name = "SoundModule"

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

Global Const SND_ASYNC = &H1     ' Play asynchronously
Global Const SND_NODEFAULT = &H2 ' Don't use default sound
Global Const SND_MEMORY = &H4    ' lpszSoundName points to a memory file

Global SoundBuffer As String


Public Sub PlaySoundRes(ByVal resID As Long)
    Dim Ret As Variant
    
    #If Win32 Then
        SoundBuffer = StrConv(LoadResData(resID, "SOUND"), vbUnicode)
    #Else
        SoundBuffer = LoadResData(resID, "SOUND")
    #End If
    Ret = sndPlaySound(SoundBuffer, SND_ASYNC Or SND_NODEFAULT Or SND_MEMORY)
    DoEvents
End Sub

Public Sub EndPlaySound()
    Dim Ret As Variant
    Ret = sndPlaySound(0&, 0&)
End Sub
