dedecms织梦内容管理系统    
首页 | java | C/C++ | PHP | 操作系统 | ajax | 脚本编程 | 安全技术 | 本站下载页 | flex | CRM | 专题 | QQ群 | 测试中心 | 会员中心 | 积分规则
  当前位置:主页>C/C++>文章内容
游戏及学习控制管理器
来源:本站原创     作者:    

原帖及讨论:

/*控制主程序control.exe*/
#include<stdio.h>
#include<string.h>
#include<dos.h>
#define MAX 100
typedef struct
{
        char name[30];
        char path[100];
        char exename[30];
        char taskname[30];
} list;
list gamelist[MAX];
char password[20];
int recordnum;
int points;

char p[70];
int initcontrol()
{
    FILE *input,*output;
    char temp[80];
    int i;
    input=fopen("Control.ini","r");
    output=fopen("Control.tmp","w");
    while(!feof(input))
    {
      fgets(temp,80,input);
      if(temp[0]!=';') fputs(temp,output);
    }
    fclose(input);
    fclose(output);
    input=fopen("Control.tmp","r");      
    fscanf(input,"%d",&recordnum);
    for(i=0;i<recordnum;i++) fscanf(input,"%s%s%s%s",gamelist[i].name,gamelist[i].path,gamelist[i].exename,gamelist[i].taskname);
    fclose(input);
    input=fopen("Control","r");
    fscanf(input,"%d%s",&points,password);
    fclose(input);
}
int startgame(int time)
{
    int n;
    int i;
    printf("\n请选择游戏:1-%d\n",recordnum);
    for(i=0;i<recordnum;i++) printf("%d.%s\n",i+1,gamelist[i].name);
    choice:
    scanf("%d",&n);
    if(n<=recordnum && n>0)
    {
      sprintf(p," %s %d",gamelist[n-1].taskname,time);
      spawnl(1,"D:\\control\\break.exe",p,NULL);
      chdir(gamelist[n-1].path);
      system(gamelist[n-1].exename);
    }
    else
    {
      printf("序号错误!请重新选择\n");
      goto choice;
    }
}
int main(void)
{
    int i=0;
    int n;
    int time;
    FILE *output;
    initcontrol();
    printf("SK-CHINA 2007-2008\n");
    printf("游戏总控制程序\n");
    printf("Game Control BY S.K\n");
    printf("请选择\n1.使用点数\n2.输入家长控制密码\n");
    scanf("%d",&n);
    if(n==1)
    {
      printf("现有点数:%d\n你游戏的每分钟将耗点数1\n",points);
      printf("请设定游戏时间 [单位:分钟]\n");
      re:
      scanf("%d",&time);
      if(time>points)
      {
        printf("点数不够,请重新输入\n");
        goto re;
      }
      points=points-time;
      output=fopen("Control","w");
      fprintf(output,"%d\n%s",points,password);
      startgame(time);
    }
    if(n==2)
    {
      printf("\n请输入家长控制密码:");
      while(p[i]=getch())
      {
        if(p[i]==13) break;
        if(p[i]!='\b')
        {
          printf("*");
          i++;
        }
        else
        {
          printf("\b \b");
          i--;
        }
      }
      p[i]='\0';
      if(strcmp(password,p)==0)
      {
        printf("\n密码通过!");
        printf("请设定游戏时间 [单位:分钟]\n");
        scanf("%d",&time);
        startgame(time);
      }
      else
      {
        printf("\n密码错误!按任意键退出");
        getch();
        exit(1);
      }
    }    
}
/*控制关闭程序break.exe*/
DEV-CPP 32位C工程
#include<stdio.h>
#include<dos.h>
#include<string.h>
int main(int argc,char **argv)
{
  int t;
  int i;
  char s[100];
  if(argc>2)
  {
    sscanf(argv[2],"%d",&t);
    sleep(t*60000);
    sprintf(s,"taskkill /im %s /f",argv[1]);
    system(s);
  }
  return 0;
}
/*学习控制器 study.exe 比较简陋的,有待更新*/
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<dir.h>
int main(void)
{
    time_t time1,time2;
    int n;
    int x;
    int points;
    char path[100];
    char password[20];
    FILE *input,*output;
    printf("你可以通过学习英语获取游戏点数,每一分钟的学习将获得一点游戏点");
    printf("\n是否学习?[1.学习 2.终止]");
    scanf("%d",&n);
    if(n==1)
    {
            getcwd(path,100);
            chdir("D:\\ruanjian\\New Oriental Soft\\New Oriental Words 4\\"); /*这是一个学习软件的路径*/
            time1=time(NULL);
            system("Recite4.exe"); /*学习软件的程序名*/
            time2=time(NULL);
            x=(int)(difftime(time2,time1)/60);
            chdir(path);
            input=fopen("control","r");
            fscanf(input,"%d%s",&points,password);
            points=points+x;
            fclose(input);
            output=fopen("control","w");
            fprintf(output,"%d\n%s",points,password);
            fclose(output);
    }
    return 0;
}
/* 控制配置 control.ini 可编辑*/
;==================================================================
;==================================================================
;记录方式:注释→ “;”后
;游戏控制总记录
;==================================================================
;记录总数
4
;==================================================================
;详细记录
;记录方式:
;游戏名
;游戏路径
;应用程序名
;进程名
三国群英传II
D:\SANGO2\
Sango2.exe
Sango2.exe
游戏王
D:\a\
VisualBoyAdvance.exe
VisualBoyAdvance.exe
超级玛莉
D:\control\
mario.exe
ntvdm.exe
吃虫子
E:\Games\休闲类\吃虫子\
runturkeyrun.exe
ZapSpot.exe
;==================================================================
/*密码控制 点数控制 未加密 control*/
100
123456
编译后组成文件共有5个
分别为control.exe break.exe study.exe control.ini control
完整程序包下载:
点击下载该文件

本程序为了控制孩子学习与游戏的度,可以说是一个可以使用的雏形,如果需要应该对control加上加密算法,study也有一定的简化,应该类似control也设置study.ini

 

 

上一篇:函数型计算器(VC++6.0,win32 console)   下一篇:程序测试程序(配合游戏及学习控制管理器使用)
[收藏] [推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
用户名: 新注册) 密码: 匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论
  热点文章
·C语言学习
·C语言指针
·C语言数组排序小结
·c语言 最简单的推箱子游戏
·c语言 全国计算机编程大赛复赛试
·c语言 全国计算机编程大赛复赛试
·c++ 数组与指针
·C++中的内存管理(new、delete、
·如何用C语言开发DSP嵌入式系统
·如何用C语言开发DSP嵌入式系统
·Linux下C语言编程
·学习arm的话先看哪本书?
  相关文章
·函数型计算器(VC++6.0,win32 con
·程序测试程序(配合游戏及学习控
·三言两语,妙说《指针》。
·很怀旧的游戏--吃豆子
·关于制作地图时矩阵的使用(适合
·编程证明出世界未解数学问题
·带符号数表示--机器数与真值--原
·最新Dev-c++与Allegor平台的搭建
·关于main()函数
·C语言开发平台的搭建
·编程初学者易犯的毛病
·C语言猜数字游戏重写版
  相关信息
copy right @ 百家拳软件项目研究室 2007 辽ICP备07011763