Re: using PlaySound within a dll



Thanks again for the ideas however my problem persists! One last
attempt before I give up on this...

I have now tried to simplify and compare:

The following code behind a form in an exe works fine:

Private Declare Function PlaySoundLong Lib "winmm.dll" Alias
"PlaySoundA" ( _
ByVal lpszName As Long, _
ByVal hModule As Long, _
ByVal dwFlags As Long) As Long

Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (
_
ByVal lpszName As String, _
ByVal hModule As Long, _
ByVal dwFlags As Long) As Long

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

Private Sub Command1_Click()
Dim x As Long
x = PlaySoundLong(101, App.hInstance, SND_RESOURCE Or SND_ASYNC)
If x = 0 Then MsgBox "FAILED!"
End Sub


But what I want to work is this:

Code behind form in exe:

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

Code in dll Class1:

Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (
_
ByVal lpszName As String, _
ByVal hModule As Long, _
ByVal dwFlags As Long) As Long

Private Declare Function PlaySoundLong Lib "winmm.dll" Alias
"PlaySoundA" ( _
ByVal lpszName As Long, _
ByVal hModule As Long, _
ByVal dwFlags As Long) As Long

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

Public Sub MySound()
Dim X As Long
X = PlaySoundLong(101, App.hInstance, SND_RESOURCE Or SND_ASYNC)
If X = 0 Then MsgBox "FAILED!"
End Sub

It is the same code, yes? Why why why is there no sound? Even in the
dll case, X is returning true but I hear nothing.

Any more thoughts?
Stacy

.



Relevant Pages

  • Re: Start-Stop-Detect services running.
    ... Private Const SERVICE_WIN32_OWN_PROCESS As Long = &H10 ... Private Sub Class_Initialize ... Public Property Get BOFAs Boolean ... Dim ServiceStat As SERVICE_STATUS ...
    (microsoft.public.vb.general.discussion)
  • Re: Visual basic for a rightkey command
    ... Dim arrAs Long ... Sub Displaycursor() ... Private Const MOUSEEVENTF_LEFTDOWN = &H2 ... Dim lFlags As Long ...
    (microsoft.public.excel.programming)
  • Re: Not showing forms outline when resizing
    ... specific aspect ratio while he is doing so? ... Private Sub Form_Load ... Private Const GWL_WNDPROC As Long = ... AddressOf WindowProc) ...
    (microsoft.public.vb.general.discussion)
  • Re: Threading Model
    ... > Private Const CREATE_ALWAYS As Long = 2 ... > ByVal hFile As Long, ByVal lDistanceToMove As Long, _ ... > ByVal nNumberOfBytesToWrite As Long, ... > Public Sub LockFile() ...
    (microsoft.public.vb.com)
  • Re: set textbox cursor in mouse right-click
    ... Sub SetCursorInTextboxRightMouseDown ... Static bDone As Boolean ... Private Const MOUSEEVENTF_LEFTDOWN = &H2 ...
    (microsoft.public.excel.programming)