我想要在窗口中播放背景音乐,但是没有声音,是我的代码有问题吗?也没有报错啊,路径也没有问题,求帮忙。
#include<graphics.h>
#include<conio.h>
#include<stdio.h>
#include<Mmsystem.h>
#include<Windows.h>
#include <tchar.h>
#pragma comment(lib,"winmm.lib")
#define width 800// 宽
#define high 500 //高
int gameStatus;
IMAGE img_bk1, img_bk2;
int start() {
initgraph(width, high);
setbkcolor(BLUE);
cleardevice();
loadimage(&img_bk1, L"C://Users//用户//source//repos//祖玛//混合背景.png", width, high);
//loadimage(&img_bk2, L"C://Users//用户//source//repos//祖玛//戴夫.jpg", 70, 150);
putimage(0, 0, &img_bk1);
putimage(30, 200, &img_bk2);
setbkmode(TRANSPARENT);
settextcolor(WHITE);
settextstyle(50, 0, _T("黑体"));
outtextxy(width * 0.3, high * 0.2, L"1 新游戏");
outtextxy(width * 0.3, high * 0.3, L"2 退出");
FlushBatchDraw();
ExMessage m;//定义鼠标信息
while (true)
{
// 获取一条鼠标或按键消息
m = getmessage(EM_MOUSE | EM_KEY);
switch (m.message)
{
case WM_MOUSEMOVE:
break;
case WM_LBUTTONDOWN:
if ( m.x >= width * 0.3 && m.x <= width * 0.7&& m.y >= high * 0.2 && m.y <= high * 0.25)
{
gameStatus = 1;
return(0);
}
else if ( m.x >= width * 0.3 && m.x <= width *0.7 && m.y >= high * 0.3 && m.y <= high * 0.35)
{
gameStatus = 2;
exit(0);
}
break;
}
}
}
int main() {
mciSendStringW(L"open C://Users//用户//source//repos//祖玛// 03.wav",0, 0, 0);
mciSendStringW(L"play C://Users//用户//source//repos//祖玛//03.wav repeat)", 0, 0, 0);
start();
cleardevice();
_getch();
closegraph();
return 0;
}