Re: using PlaySound within a dll

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance








"MikeD" <nobody@xxxxxxxxxxx> wrote in message
news:ujFJMeUmFHA.1048@xxxxxxxxxxxxxxxxxxxxxxx
>
> "stacy" <stacyirish@xxxxxxxxxxxxx> wrote in message
> news:1123175525.965880.59030@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> >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
>
>
> PlaySound has the capability to play a .wav file directly from the
> resource....sndPlaySound does not.

Are you sure about this?

See this sample:
http://www.veign.com/vrc_codeview.asp?type=app&id=128

--
Chris Hanscom - Microsoft MVP (VB)
Veign's Resource Center
http://www.veign.com/vrc_main.asp
--


.


Quantcast