1、动态库 Winmm.dll 调用
#include <stdio.h>
#include <windows.h>
typedef MCIERROR WINAPI (*PLAYSOUND)(LPCSTR, HMODULE,DWORD);
int main(void)
{
HMODULE hLib;
hLib = LoadLibrary("Winmm.dll");
if (hLib == 0)
return 1;
PLAYSOUND PlaySound = (PLAYSOUND)GetProcAddress(hLib, "PlaySound");
if (PlaySound == 0)
return 2;
PlaySound("C:\\TEMP\\抹去泪水(韩宝仪).wav", 0, SND_ASYNC|SND_LOOP);
printf("按任一键停止\n");
system("pause");
PlaySound(NULL, 0, SND_PURGE);
FreeLibrary(hLib);
return 0;
}
2、静态库连接:将连接库 libwinmm.a 加入项目
链接设置:项目属性--参数--链接
加入库 ../../../编程工具/Dev-Cpp/MinGW64/x86_64-w64-mingw32/lib32/libwinmm.a