展开全部
说明:以下为一示例。其中,"F:\\yy\\3.明天你好.mp3"和"F:\\yy\\2.mp3"应改为你想设定的背景音乐在你电脑中对应的路径。
#include "stdafx.h"
#include"conio.h"
#include"stdio.h"
#include<windows.h>
#include "mmsystem.h"//导入声音头文件
#pragma comment(lib,"winmm.lib")//导入声音头文件库
#include<stdio.h>
void PlayMp3(char g[]) ;
void main()
{ char k;char g1[45];
printf("\n\n\n\t\t请选择背景音乐 ( ) \n\n\n\t\t\t\tA.明天你好.\n\n\t\t\t\tB.你是我的眼.");
printf("\n\n\t\t\t\tC.静音");
k=getch();system("cls");
switch(k)
{
case'A':
case'a': strcpy(g1,"F:\\yy\\3.明天你好.mp3");break;
case'B':
case'b': strcpy(g1,"F:\\yy\\2.mp3");break;
}
PlayMp3(g1) ;
int i, j;
system("cls");
printf("\n\t\t\tIf you think your ideal has ptential\n\t\t\t\tseize on it!\n\n一花一天堂,一草一世界 \n");
for( i=0;i<200000000;i++) j++;
printf("一沙一净土,一念一心静\n\n");
for( i=0;i<200000000;i++) j++;
printf("心是莲花开\n");
printf("窗外木樨花的香味夹着泥土的芬芳飘了进来\n");
printf("冷香飞上枝头,氤氲着浓烈的新鲜\n");
printf("思绪在晨雾中抖落,清晰成窗前淙淙的诗意\n\n");
for( i=0;i<200000000;i++) j++;
printf("手捧一杯白开水在某个安静的午后轻轻呷下一口\n");
printf("淡却微甜\n");
printf("就像那晶莹的甘露滴在叶尖\n");
printf("一书如帆,慢慢咂摸\n\n");
for( i=0;i<200000000;i++) j++;
printf("经典,文明的陈酿,千年淘洗,遗存华章,哺育心灵\n");
printf("经典,不贬值的资本,璀璨夺目,点墨成金,价值永恒\n");
printf("昔我往矣,杨柳依依,今我来思,雨雪霏霏\n");
printf("爱上“掬水月在手,弄香花满衣”的日子\n");
printf("惟愿“生如夏花之绚烂,死如秋叶之静美”\n\n");
for( i=0;i<200000000;i++) j++;
printf("云淡风清,蔷薇香溢,世界万籁无声......\n");
getch();
}
//背景音乐设置函数
void PlayMp3(char g[])
{
char buf[128];
char str[128] = {0 };
int i = 0;
char g2[45]; strcpy(g2,g);
MCI_OPEN_PARMS mciOpen;
MCIERROR mciError;
mciOpen.lpstrDeviceType = "mpegvideo";
mciOpen.lpstrElementName = g2; //文件选择
mciError = mciSendCommand(0,MCI_OPEN,MCI_OPEN_TYPE | MCI_OPEN_ELEMENT,(DWORD)&mciOpen);
if(mciError)
{
mciGetErrorString(mciError,buf,128);
printf("send MCI_OPEN command failed:%s\n",buf);
return;
}
UINT DeviceID = mciOpen.wDeviceID ;
MCI_PLAY_PARMS mciPlay;
mciError = mciSendCommand(DeviceID,MCI_PLAY,0 ,(DWORD)&mciPlay);
if(mciError)
{
printf("send MCI_PLAY command failed\n");
return;
}
}
#include "stdafx.h"
#include"conio.h"
#include"stdio.h"
#include<windows.h>
#include "mmsystem.h"//导入声音头文件
#pragma comment(lib,"winmm.lib")//导入声音头文件库
#include<stdio.h>
void PlayMp3(char g[]) ;
void main()
{ char k;char g1[45];
printf("\n\n\n\t\t请选择背景音乐 ( ) \n\n\n\t\t\t\tA.明天你好.\n\n\t\t\t\tB.你是我的眼.");
printf("\n\n\t\t\t\tC.静音");
k=getch();system("cls");
switch(k)
{
case'A':
case'a': strcpy(g1,"F:\\yy\\3.明天你好.mp3");break;
case'B':
case'b': strcpy(g1,"F:\\yy\\2.mp3");break;
}
PlayMp3(g1) ;
int i, j;
system("cls");
printf("\n\t\t\tIf you think your ideal has ptential\n\t\t\t\tseize on it!\n\n一花一天堂,一草一世界 \n");
for( i=0;i<200000000;i++) j++;
printf("一沙一净土,一念一心静\n\n");
for( i=0;i<200000000;i++) j++;
printf("心是莲花开\n");
printf("窗外木樨花的香味夹着泥土的芬芳飘了进来\n");
printf("冷香飞上枝头,氤氲着浓烈的新鲜\n");
printf("思绪在晨雾中抖落,清晰成窗前淙淙的诗意\n\n");
for( i=0;i<200000000;i++) j++;
printf("手捧一杯白开水在某个安静的午后轻轻呷下一口\n");
printf("淡却微甜\n");
printf("就像那晶莹的甘露滴在叶尖\n");
printf("一书如帆,慢慢咂摸\n\n");
for( i=0;i<200000000;i++) j++;
printf("经典,文明的陈酿,千年淘洗,遗存华章,哺育心灵\n");
printf("经典,不贬值的资本,璀璨夺目,点墨成金,价值永恒\n");
printf("昔我往矣,杨柳依依,今我来思,雨雪霏霏\n");
printf("爱上“掬水月在手,弄香花满衣”的日子\n");
printf("惟愿“生如夏花之绚烂,死如秋叶之静美”\n\n");
for( i=0;i<200000000;i++) j++;
printf("云淡风清,蔷薇香溢,世界万籁无声......\n");
getch();
}
//背景音乐设置函数
void PlayMp3(char g[])
{
char buf[128];
char str[128] = {0 };
int i = 0;
char g2[45]; strcpy(g2,g);
MCI_OPEN_PARMS mciOpen;
MCIERROR mciError;
mciOpen.lpstrDeviceType = "mpegvideo";
mciOpen.lpstrElementName = g2; //文件选择
mciError = mciSendCommand(0,MCI_OPEN,MCI_OPEN_TYPE | MCI_OPEN_ELEMENT,(DWORD)&mciOpen);
if(mciError)
{
mciGetErrorString(mciError,buf,128);
printf("send MCI_OPEN command failed:%s\n",buf);
return;
}
UINT DeviceID = mciOpen.wDeviceID ;
MCI_PLAY_PARMS mciPlay;
mciError = mciSendCommand(DeviceID,MCI_PLAY,0 ,(DWORD)&mciPlay);
if(mciError)
{
printf("send MCI_PLAY command failed\n");
return;
}
}
2011-12-18
展开全部
用多线程
参考AfxBeginThread函数即可
参考AfxBeginThread函数即可
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询