怎么用PlaySound播放Wav的音频

C++语言 码拜 8年前 (2016-04-26) 1424次浏览
PlaySound(“gpwswav\-SNKRATE.wav”, NULL, SND_ASYNC| SND_NOSTOP);播放,加了#include “mmsystem.h”和#pragma comment(lib,”Winmm.lib”),但是编译时说”PlaySound” : undeclared identifier、”SND_ASYNC” : undeclared identifier、”SND_NOSTOP” : undeclared identifier。为什么总是未定义?
解决方案

10

加:
#include <Windows.h>
改:
PlaySound(TEXT(“gpwswav\-SNKRATE.wav”), NULL, SND_ASYNC| SND_NOSTOP);

10

File: "c:\Microsoft SDK\Include\prerelease\MMSystem.h" 1 occurrences found on 1 lines
    456: #define SND_ASYNC           0x0001  /* play asynchronously */
File: "c:\Microsoft SDK\Include\MMSystem.h" 1 occurrences found on 1 lines
    456: #define SND_ASYNC           0x0001  /* play asynchronously */
File: "C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Include\MMSystem.h" 1 occurrences found on 1 lines
    456: #define SND_ASYNC           0x0001  /* play asynchronously */
File: "C:\Program Files\Microsoft Visual Studio\VC98\Include\MMSYSTEM.H" 1 occurrences found on 1 lines
    469: #define SND_ASYNC           0x0001  /* play asynchronously */

10

引用:
Quote: 引用:
Quote: 引用:
Quote: 引用:
 把这个Mmsystem.h加上

已经加了,但是说”SND_ASYNC”未定义

把这句加上
#pragma comment(lib,"Winmm.lib")

这个也加了,还是说”SND_ASYNC” : undeclared identifier

这么麻烦 直接建个MFC程序 或windows程序 得了

10

第8行后面被注释掉的是循环播放,lz可以试试

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明怎么用PlaySound播放Wav的音频
喜欢 (0)
[1034331897@qq.com]
分享 (0)