求教!
打算使用mcisendstring函数做一个简陋的播放器,但是输入指令之后,没有反应,也没有卡死,几秒种后自动结束进程,何解?代码:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <mmsystem.h>
int main(int argc, char *argv[])
{
char cmd[1024];
int i;
int play,pause,stop,vd,vp,exit;
begin:printf("---------MENU-----------\n");
printf("pause stop\n");
printf("VolumeDown VolumeUp\n");
printf("play exit\n");
printf("If you want to do sth,you can enter the cmd(VolumeDown=vd,VolumeUp=vp)\n\n\n");
scanf("%s",&cmd);
if(strcmp(cmd,"play")==0)
{
mciSendString(L"open E:\\Nevada.mp3 alias music", NULL, 0, NULL);
mciSendString(L"play music", NULL, 0, NULL);
Sleep(5000);
}
else if(strcmp(cmd,"pause")==0)
{
mciSendString(L"pause music", NULL, 0, NULL);
}
else if(strcmp(cmd,"stop")==0)
{
mciSendString(L"close music", NULL, 0, NULL);
}
else if(strcmp(cmd,"vd")==0)
{
printf("Still not support.");
}
else if(strcmp(cmd,"vp")==0)
{
printf("Still not support.");
}
else if(strcmp(cmd,"resume")==0)
{
mciSendString(L"resume music", NULL, 0, NULL);
getchar();
getchar();
}
else if(strcmp(cmd,"exit")==0)
{
for(i=0;i<100;i++)
{
printf("------------------------\n");
}
return 0;
}
else
{
for(i=0;i<100;i++)
{
printf("------------------------\n");
}
printf("Commander error!\n");
goto begin;
}
return 0;
}