First, you need prepare the wav voice file in the current folder, e.g., "door2.wav" here.
Then, just 1 line code needs:
#include <windows.h>
#include "tchar.h"
#pragma comment(lib, "winmm.lib")
int main()
{
PlaySound( _T("door2.wav"), NULL, SND_SYNC);
return 0;
}
本文介绍如何使用C++编程语言,通过简单的代码片段,实现播放本地wav音频文件的功能。利用PlaySound函数,轻松地将声音文件融入您的程序中。
5940

被折叠的 条评论
为什么被折叠?



