We help IT Professionals succeed at work.
Get Started

PlaySound fails on Windows 7

LogicMan2006 asked
Last Modified: 2013-11-20
I've got a fairly large VS2008/MFC application that has been around for quite some time.    The program has functionality to have sounds played (using PlaySound) when certain events occur.   It's seldom used and frankly I rarely test anything to do with it.  So,  I didn't notice that at some point the PlaySound quit working with Windows 7.      I can take a current version of the program and it works fine on Windows XP, but nothing happens on Windows 7.   I can get small sample apps to work ok in W7 using the same WAV files so I know this not related to the WAV file itself.

The code is basically this:
  PlaySound(_T("C:\\Windows\Media\\Tada.wav"), NULL,  SND_FILENAME | SND_ASYNC );

What I've done so far is:
1)  Tried different combinations of the SND_* constants.
2)  Tried creating another thread and executing it there using SND_SYNC
3)  Tried removing as many  dependencies on outside libraries as possible.
4)  Tried playing WAV files that come with Windows, Aliases.   Nothing works in this application, but does in test applications.

As I said,  I can create test apps that work ok.    If I play the sound using SND_SYNC, it fails but you can't use GetLastError() to find out why.   Using SND_ASYNC will cause PlaySound to always return
true, but no sound comes out.   I'm really at a loss with this.   Clearly there's something I'm doing to cause the problem but at this point I don't know how to troubleshoot this any further.   Does anyone have any idea what I could do to cause this to occur?

Watch Question
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE