如何用C语言编写系统关机注销的代码?

2026-04-29 18:005阅读0评论SEO资讯
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计373个文字,预计阅读时间需要2分钟。

如何用C语言编写系统关机注销的代码?

本例展示了一家分享了C语言实现系统关机功能的整体代码,供大家参考学习。具体内容如下:

本文实例为大家分享了C语言实现系统关机注销的具体代码,供大家参考,具体内容如下

#include<stdio.h> //printf #include<stdlib.h> //system #include<string.h> //strcat---exit int 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); }

效果:

如何用C语言编写系统关机注销的代码?

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持自由互联。

本文共计373个文字,预计阅读时间需要2分钟。

如何用C语言编写系统关机注销的代码?

本例展示了一家分享了C语言实现系统关机功能的整体代码,供大家参考学习。具体内容如下:

本文实例为大家分享了C语言实现系统关机注销的具体代码,供大家参考,具体内容如下

#include<stdio.h> //printf #include<stdlib.h> //system #include<string.h> //strcat---exit int 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); }

效果:

如何用C语言编写系统关机注销的代码?

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持自由互联。