Current location - Music Encyclopedia - NetEase Cloud Music - How to open music files in MFC
How to open music files in MFC

1. Use the PlaySound() function

The prototype of this function is:

BOOL PlaySound(

LPCSTR pszSound,

p>

HMODULE hmod,

DWORD fdwSound

)

Among them, the parameter pszSound specifies the file name of the file to be played. If the parameter is NULL, Then stop the sound being played;

The parameter hmod specifies the handle of the resource;

The parameter fdwSound specifies the flag of the command, which means the way to play the WAV file

< p>Example:

//Play call2.wav

PlaySound("call2.wav",NULL,SND_FILENAME | SND_ASYNC | SND_LOOP);

// Turn off the sound

PlaySound(NULL,NULL,SND_FILENAME | SND_ASYNC | SND_LOOP);