| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 794 人关注过本帖
标题:求教!
只看楼主 加入收藏
龙魂汉化
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2018-8-24
收藏
 问题点数:0 回复次数:0 
求教!
打算使用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;
}
搜索更多相关主题的帖子: include cmd printf strcmp NULL 
2018-12-10 15:53
快速回复:求教!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.014522 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved