We help IT Professionals succeed at work.

Cannot silence a looping sound from a VB6 app

mfenske17363
mfenske17363 asked
on
We have a legacy VB 6 app that uses the PlaySound function in winmm.dll to play .WAV files.  Some sounds are played in a loop (SND_ASYNC+SND_LOOP) while others are not.  The user silences the looping sounds by pressing a key which calls PlaySound again using a .WAV file that is empty and the options SND_PURGE + SND_NODEFAULT.

This code has worked for a long time (and continues to work) with WIndows XP 32-bit.

When run on a Windows 7 64-bit OS the single sound works as before but attempting to use the existing code to silence the looping sound does not work (the sound continues to play until the process is killed).

Anyone experience this behavior?

What is the fix for this?

Thanks!
Comment
Watch Question

Mike TomlinsonHigh School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
CERTIFIED EXPERT
Top Expert 2009

Commented:
I've used this before, but haven't tested it on Win 7 x64:

    Private Sub StopWav()
        PlaySound vbNullString, ByVal 0&, SND_PURGE
    End Sub
Well AFTER reading the latest MSDN description it appears SND_PURGE is no longer supported and the correct way to silence the looping sound is:

PlaySound vbNull, 0, SND_ASYNC

I suppose vbNullString works as well I'm not a VB expert

Author

Commented:
No other answer was correct

Explore More ContentExplore courses, solutions, and other research materials related to this topic.