Play wav voice file in console program

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;
}


猜你喜欢

转载自blog.csdn.net/DavyHwang/article/details/8078040