PlaySound

Bool PlaySound(LPCTSTR pszSound,//播放声音文件地址,NULL表示停止,想要只写文件名.wav就把wav和cpp放一起
HMODULE hmod,//声音文件的句柄
DWORD fdwSound);//控制声音播放
需要连接winmm.lib
方法是
#pragma comment(lib,“winmm.lib”)
或者:
项目-属性-链接器-输入-附加依赖项-编辑
在这里插入图片描述

fdwSound 如下:
#define SND_SYNC 0x0000 /* play synchronously (default) / 同步
#define SND_ASYNC 0x0001 /
play asynchronously / 异步
#define SND_NODEFAULT 0x0002 /
silence (!default) if sound not found /
#define SND_MEMORY 0x0004 /
pszSound points to a memory file / 内存读取声音
#define SND_LOOP 0x0008 /
loop the sound until next sndPlaySound /
#define SND_NOSTOP 0x0010 /
don’t stop any currently playing sound */

#define SND_NOWAIT 0x00002000L /* don’t wait if the driver is busy /
#define SND_ALIAS 0x00010000L /
name is a registry alias /
#define SND_ALIAS_ID 0x00110000L /
alias is a predefined ID /
#define SND_FILENAME 0x00020000L /
name is file name / 文件读取声音
#define SND_RESOURCE 0x00040004L /
name is resource name or atom /
#if (WINVER >= 0x0400)
#define SND_PURGE 0x0040 /
purge non-static events for task /
#define SND_APPLICATION 0x0080 /
look for application specific association /
#endif /
WINVER >= 0x0400 /
#define SND_SENTRY 0x00080000L /
Generate a SoundSentry event with this sound /
#define SND_RING 0x00100000L /
Treat this as a “ring” from a communications app - don’t duck me /
#define SND_SYSTEM 0x00200000L /
Treat this as a system sound */

猜你喜欢

转载自blog.csdn.net/liuyx91/article/details/90050560
今日推荐