You can use Win32 API PlaySound
#include "windows.h"
#include "mmsystem.h"
#pragma comment (lib,"winmm.lib")
int main(int argc, char* argv[])
{
PlaySound(TEXT("c: \\test.wav"), NULL, SND_FILENAME | SND_ASYNC );
or
sndPlaySound("c:\\test.wav", SND_ASYNC | SND_NODEFAULT); //Play
return 0;
}
Playback flags and meanings:
SND_APPLICATION uses the application-specified association to play the sound.
The SND_ALIAS pszSound parameter specifies the alias of the system event in the registry or WIN.INI.
SND_ALIAS_ID The pszSound parameter specifies a predefined sound identifier.
SND_ASYNC plays sound asynchronously, and the PlaySound function returns immediately after starting playback.
SND_FILENAME The pszSound parameter specifies the WAVE file name.
SND_LOOP plays the sound repeatedly and must be used together with the SND_ASYNC flag.
SND_MEMORY plays the sound loaded into the memory. At this time, pszSound is the pointer to the sound data. SND_NODEFAULT does not play the default sound. If there is no such flag, PlaySound will play the default sound if no sound is found.
SND_NOSTOP PlySound does not interrupt the original sound playback and returns FALSE immediately.
SND_NOWAIT If the driver is busy, the function does not play the sound and returns immediately.
SND_PURGE stops all sounds related to the calling task. If the parameter pszSound is NULL, stop
all sounds, otherwise, stop the sound specified by pszSound.
SND_RESOURCE The pszSound parameter is the identifier of the WAVE resource. In this case, the hmod parameter is used.
SND_SYNC plays the sound synchronously, and the PlaySound function does not return until the playback is completed.