Re: using PlaySound within a dll



I have compiled and run and still no sound. Maybe someone can recreate
what I am trying to do to find my mistake...

I have an exe with a form and a button. The code behind the button is:

Private Sub Command1_Click()
Dim X As New dllSound.Class1
X.MySound
X.MyMessage
End Sub

I have a dll with a module, class and resource file.

The module code is:

Declare Function sndPlaySound Lib "WINMM.DLL" Alias "sndPlaySoundA" ( _
ByVal lpszSoundName As String, _
ByVal uFlags As Long) As Long

Declare Function PlaySound Lib "WINMM.DLL" Alias "PlaySoundA" ( _
ByVal lpszName As String, _
ByVal hModule As Long, _
ByVal dwFlags As Long) As Long

Declare Function PlaySoundLong Lib "WINMM.DLL" Alias "PlaySoundA" ( _
ByVal lpszName As Long, _
ByVal hModule As Long, _
ByVal dwFlags As Long) As Long

Public Const SND_ASYNC = &H1
Public Const SND_NODEFAULT = &H2
Public Const SND_MEMORY = &H4
Public Const SND_SYNC = &H0
Public Const SND_RESOURCE = &H40004

The class code is:

Public Sub MySound()

Dim X As Long
Dim DataArray() As Byte
DataArray = LoadResData(101, "WAVE")
'X = PlaySound(DataArray(0), App.hInstance, SND_MEMORY Or
SND_NODEFAULT Or SND_ASYNC)
X = sndPlaySound(DataArray(0), SND_ASYNC Or SND_NODEFAULT Or
SND_MEMORY)
Erase DataArray

MsgBox "App.hInstance within dll " & App.hInstance, vbOKOnly
MsgBox "X return value " & X, vbOKOnly

End Sub

Public Sub MyMessage()
MsgBox "This is a message from the dll.", vbOKOnly
End Sub


When I compile and run the exe I see all my messages from the dll but
never hear the sound.

Thanks for the help,
Stacy

.