Embed file in Application

Greetings,

I am trying to make my application to play sound. I know there is a PlaySound() function which can easily accomplish it. However, I realized that this method requires a music file to exist on the computer.

I am wondering if it is possible to embed the music file into an application, so I don't need the music file to be on the computer to play sound?

Any suggestion is appreciated!
[425 byte] By [kabilius] at [2007-11-20 8:52:20]
# 1 Re: Embed file in Application
You can add the wav file as resource and then use ::PlaySound() with SND_RESOURCE.

Cheers
golanshahar at 2007-11-9 13:30:48 >
# 2 Re: Embed file in Application
See also http://www.dev-archive.com/forum/showthread.php?t=424933
S_M_A at 2007-11-9 13:31:48 >
# 3 Re: Embed file in Application
Greetings,

Yes! I used PlaySound() with SND_RESOURCE like golanshahar and S_M_A suggested, and it is working fine.

From my experience, couple things to watch out when using this method:
1. add winmm.lib to your project
2. use MAKEINTRESOURCE() along with the resource id of the .wav file.

Thank you both for helping me out!
kabilius at 2007-11-9 13:32:46 >