帮我写一段c++自动播放bag包的程序
时间: 2023-05-28 09:05:33 浏览: 266
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
int main()
{
//定义需要播放的音乐文件路径
const char* music_path = "bag.mp3";
//定义需要等待的时间(毫秒)
const int wait_time = 3000;
//播放音乐
printf("Playing music...\n");
PlaySound(music_path, NULL, SND_FILENAME | SND_ASYNC);
//等待一定时间
printf("Waiting for %d milliseconds...\n", wait_time);
Sleep(wait_time);
//停止播放音乐
printf("Stopping music...\n");
PlaySound(NULL, NULL, 0);
return 0;
}
阅读全文