Re: using PlaySound within a dll
- From: "stacy" <stacyirish@xxxxxxxxxxxxx>
- Date: 4 Aug 2005 10:12:06 -0700
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
.
- Follow-Ups:
- Re: using PlaySound within a dll
- From: MikeD
- Re: using PlaySound within a dll
- From: Tom Esh
- Re: using PlaySound within a dll
- From: Thorsten Albers
- Re: using PlaySound within a dll
- References:
- using PlaySound within a dll
- From: stacy
- Re: using PlaySound within a dll
- From: Ken Halter
- Re: using PlaySound within a dll
- From: stacy
- Re: using PlaySound within a dll
- From: Bob Butler
- Re: using PlaySound within a dll
- From: stacy
- Re: using PlaySound within a dll
- From: MikeD
- using PlaySound within a dll
- Prev by Date: Re: using PlaySound within a dll
- Next by Date: Re: Save file Dialog API question
- Previous by thread: Re: using PlaySound within a dll
- Next by thread: Re: using PlaySound within a dll
- Index(es):