Pinyo's Programming and Software Notes

Wednesday, June 28, 2006

Play sound in Windows C++
(June 28, 2006)

To play a wav file, we can use PlaySound function. This function is provided as a part of Windows Platform SDK: Windows Multimedia (ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/multimed/mmfunc_9uxw.htm).

To play sound asynchronously, we may code
PlaySound( "D:/begin.wav", NULL, SND_FILENAME | SND_ASYNC );.
It is important to note that the declaration of the function is in #include "Mmsystem.h", and the library we need is
Winmm.lib. To include the library in Visual Studio .Net 2003, we can go to Configuration Properties::Linker::Command Line. Then, specify the library name by typing the name in "Addition Options" (say winmm.lib in the box, that's it).

0 Comments:

Post a Comment

<< Home