c语言实现系统关机注销等功能

来源:互联网 发布:电脑数据恢复多少钱 编辑:程序博客网 时间:2024/05/16 07:43
#include<stdio.h>//printf#include<stdlib.h>//system #include<string.h>//strcat---exitint print(){int n;printf("*****c语言关机程序*****\n");printf("1:实现十分钟内定时关机\n");printf("2:立即关闭计算机\n");printf("3:注销计算机\n");printf("0:退出系统\n");printf("请输入你要选择的功能0——3:\n");scanf("%d",&n);return n;}void main(){system("title  c语言关机程序");        //设定dos窗口名称system("mode con cols=100 lines=100"); //列column,行lines,将dos窗口转化为100行,100列system("color 0B");                    //0(即前者)幕背景颜色,B(即后者)前背景颜色system("date /T");                     //打印系统当前时间  /T作用不太清楚 system("TIME /T");       //打印系统当前日期char cmd[20]="shutdown -s -t";         //-s关闭计算机,-t延迟时间,char t[5]="0";int c = print();getchar();switch(c){case 1:printf("您想在多少秒后自动关闭计算机?(0--600)\n");scanf("%s",t);system(strcat(cmd,t));    //"system -s -t 100"延迟100秒之后关闭计算机break;case 2:system("shutdown -p");  //仅关闭本地计算机break;case 3:system("shutdown -l");    //-l:注销当前用户break;case 0:break;default:printf("error\n");}system("pause");            //冻结屏幕,便于观察程序的执行结果exit(0);}

0 0
原创粉丝点击