In VC + + program design, you can use a variety of standard resources, such as bitmaps, menus, dialog boxes and so on. At the same time, VC + + allows users to customize resources, so we can use the sound file as a user-defined resource into the program resource file, compiled connection generated EXE file, achieve none. WAV file for sound playback.
The steps are as follows:
1. Add in the Dlg.h
#include <windows.h>
#include <mmsystem.h>//Plus, otherwise the PlaySound function cannot be used
#pragma comment (lib, "WINMM. LIB ")//Plus, otherwise the PlaySound function cannot be used
2. Load the resource. wav file
Open Explorer, right-click RC, Load resources, import. wav files
3. Add a button
Double-click the button generation function
4. In the generated function
PlaySound (Makeintresource (idr_wave1), AfxGetResourceHandle (), snd_async| snd_resource| Snd_nodefault);//one-time playback
PlaySound (Makeintresource (idr_wave1), AfxGetResourceHandle (), snd_async| snd_resource| Snd_nodefault| Snd_loop);//Loop play
Description: There are many ways to play sound, one is enough for me. What's the problem welcome to explore together.
MFC click button to make sound _playsound_ loop/Single Play _ Sound file join program