C语言PlaySound demo

#include <windows.h>
#include <mmsystem.h>
#include <stdio.h>
//#pragma comment(lib, "Winmm.lib")


int main(int argc, char *argv[])
{
PlaySound (TEXT("D:\\sound\\Speech Off.wav"), NULL, SND_FILENAME | SND_NODEFAULT);
     printf("start...");
    
return 0;
}

注意://#pragma comment(lib, "Winmm.lib")  这个引用在code::blocks IDE下无效.需要 右键选择项目—>Build Options->linker settings ->Other linker options 中添加 “-lwinmm” (不带引号)

原文地址:https://www.cnblogs.com/ikodota/p/2922611.html