Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Playing wav files in a program. 2

Status
Not open for further replies.

nicktherod

Programmer
Nov 10, 2000
19
0
0
CA
I want to play a wav file in my program. For example when a user reply yes to a message box i would like to play the windows Tada.wav.

Many thanks in advance.

Nick
 
I've just tried the PlaySound function and i just get a compiling error. The compiler doesn't recognise it. Maybe i am missing a piece of the puzzle.
 
Another thing that might work (I didn't try it) is to use the ShellExecute function. That should allow you to "launch" a wave file, just as if it had been double clicked in Windows Explorer.
 
What kind of error did you get with PlaySound? You need a handle to HMODULE and i think (but can't remember and am not on a machine with MSDN) need to include mmsystem.h This is how I usually play sounds.

HMODULE hmodThis = GetModuleHandle(NULL);
PlaySound(m_sPath, hmodThis, SND_FILENAME | SND_ASYNC);


HTH,
JC
 
Mongoose. I tried your code, but i get a linking error.
 
Keith

I tried the ShellExecute, but it opens open RealJukebox to play it, which is not really what i want.

thanx for the suggestion though.
 
Nick,

PlaySound should work. You don't say what the linking error is, but have you included winmm.lib in your project. This contains PlaySound and other multimedia API's.

tony.dean@aeat.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top