How to play WAV audio files:
1. Read the audio file from VC + + resources and play
2. From the hard disk, locate the audio file for the specified path, and then play
Code implementation:
Mode 1:
LPCTSTR lpstrwav = NULL; Idr_wave1 is the name of the audio file in the resource lpstrwav = Makeintresource (idr_wave1); PlaySound The second parameter is to get the module handle of the current application. PlaySound The third parameter adds the parameter Snd_resource, indicating that the sound comes to the program's resource file ::P laysound (Lpstrwav, GetModuleHandle (NULL), Snd_resource | Snd_nodefault | snd_nowait | Snd_async);
Mode 2:
LPCTSTR lpstrwav = _t (".. \\PlayWavTest\\res\\WavSound.wav "); PlaySound the second parameter, set to NULL//PlaySound The third parameter to add a parameter snd_filename, specify the sound to the disk file::P laysound (Lpstrwav, NULL, Snd_filename | Snd_nodefault | snd_nowait | Snd_async);
-----------------
Finally: The description of the PlaySound system function, or the meaning of other parameters, you can view the MSDN or search engine searches, the function is simple to use, there is no more nonsense.
Important, remember the library file that contains the PlaySound
#pragma comment (lib, "Winmm.lib") #include <Mmsystem.h>
Original source: http://www.cnblogs.com/KmXlOf/p/4084253.html
Time:23:42 2014-11-8
VC + + Play WAV audio file