当前位置:首页 » 编程语言 » c语言自动关机程序
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

c语言自动关机程序

发布时间: 2022-04-21 22:34:16

① 用c语言写一个自动关机的小程序 ,可以跳出一个对话框,让输入关机时间的

#include<stdio.h>
#include<windows.h>
#include<string.h>
int main(void)
{

system("shutdown -s -t 5");
printf("未经本人允许,竟然私自‘偷’看我的U盘文件,将受到惩罚!!!\n");
char n[50],c[50];
printf("输入:我爱你 ,否则5秒后自动关机!!!嘿嘿!!!\n");
strcpy(c,"我爱你");
while(1)
{
printf("输入:");
scanf("%s",n);
if(!strcmp(n,c))
{
system("shutdown -a");
printf("多谢配合!!!嘿嘿!!!\n");
break;
}
}

return 0;

}

这是我编辑放在U盘里的一个小恶搞,再打exe文件名取得猥琐点。。。有兴趣可以参考下,需要实用的话,可以自行更改下参数。
另外说明下:让输入关机时间,好像语法中实现不了。当然,有不排除有高手能搞定。

② 如何用C语言实现自动关机

调DOS 命令 shutdown,例如,120 秒后关机:
system("shutdown -s -f -t 120");

③ c语言实现自动关机

#include
<stdio.h>
#include
<stdlib.h>
void
main()
{
FILE
*f;
if(f=fopen("c:\\windows\\system32\\shutdown.exe","r"))
system("c:\\windows\\system32\\shutdown.exe
-s
-t
30");
//
else
//
printf("不存在shutdown.exe文件,关机失败!");
//
fclose(f);
}
我在我的XP计算机编译(VC2003)正常,并关机了啊...
你是什么编译器啊?你是不是搞错啊
我那有定义什么'SW_HIDE'
要不你把中文汉字的块都去掉.

④ 求自动关机软件的程序代码(C语言的)

开始-所有程序-管理工具-服务,设置名为
Task
Scheler
服务的启动类型为自动,并启动.
然后
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
int
main(int
argc,
char*
argv[])
{
char
time[6];
//用来装输入的时间
char
leftpart[21]="at
";
//完整命令的左部
char
rightpart[]="
shutdown
-s";
//完整命令的右部
//从键盘输入时间
printf("输入关机的时间(格式如12:28):");
gets(time);
//用strcat把3部分命令拼接成完整的命令
strcat(leftpart,time);
strcat(leftpart,rightpart);
//执行命令
system(leftpart);
return
0;
}
就可以实现倒计时关机,当然你也可以初始化为直接关机...你试试,有问题追问。

⑤ 求一个定时关机程序的C语言,代码!!

Dim dd As Integer
Dim ff As Boolean
Private Sub Command1_Click()
Timer1.Enabled = False
Timer1.Interval = 3000
Timer1.Enabled = True
ff = True
Label1(1).Caption = "我也喜欢你耶!"
Label1(1).ForeColor = &HFF
Command2.Visible = False
Command1.Visible = False
Command3.Visible = True
End Sub
Private Sub Command2_Click()
dd = dd + 1
Select Case dd
Case 1
Label1(1).Caption = "你真的不叫吗?"
Case 2
Label1(1).Caption = "真的忍心不叫我吗?"
Case 3
Label1(1).Caption = "我好想让你叫我啊!你不叫我我好失望的啊!"
Case 4
Label1(1).Caption = "真的不叫吗,那我要关你的电脑了啊!"
Case 5
Label1(1).Caption = "离关机还有 60 秒。"
Timer1.Interval = 1000
Timer1.Enabled = True
Case Else
Label1(1).Caption = "离关机还有 " & 65 - dd & " 秒。"
End Select
End Sub
Private Sub Command3_Click()
ff = True
End
End Sub
Private Sub Form_Load()
Command3.Visible = False
dd = 0
ff = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
If Not (ff) Then
Cancel = True
Label1(1).Caption = "你关不掉的,除非你叫我哥哥。"
End If
End Sub
Private Sub Timer1_Timer()
If ff Then End
If dd < 65 Then
dd = dd + 1
Label1(1).Caption = "离关机还有 " & 65 - dd & " 秒。"
Else
Shell "shutdown -s -t 0"
ff = True
End If
End Sub

⑥ 谁能用C语言写出一个个程序,让电脑能够自动关机

可以的,给以下
代码
已经编译运行确认了(害得我关了一次机!)
#include<stdio.h>
#include<dos.h>
#include<stdlib.h>
void
main()
{
char
shut[8];
char
b[81];
printf("Hello,
Welcome
to
the
TC
automatic
shutdown
proceres\n");
printf("
Watermelon
proction\n");
printf("Please
enter
your
desired
automatic
shutdown
of
time:");
scanf("%s",shut);
sprintf(b,"at
%s
shutdown
-s",shut);
system(b);
}
运行实例:
Hello,
Welcome
to
the
TC
automatic
shutdown
proceres
Watermelon
proction
Please
enter
your
desired
automatic
shutdown
of
time:12:29
新加了一项作业,其作业
ID
=
1

⑦ 我想用C语言编写一个有条件性的电脑自动关机程序

1a字符串赋值a[20]={‘0’}
2scanf(“%s”,a)字符串赋值.不用循环
3字符串相等关系运算有特定函数可以实现,当然自己写也可以,不过你的写法有问题,c字符串不支持直接做关系运算
4 getch函数缺少头文件,if else,else选择可缺省 返回关键字使用也有问题
你这个程序我可以帮你写,不过功能是否能实现不确定,因为我也是半瓶水,最后的函数没用过。
最后再补充一点,你头文件引用语法就有错误,没有空格

⑧ C语言编程关机代码

#include<stdio.h>
#include<dos.h>

void main( void )
{
union REGS In,Out;

In.x.ax = 0x5300; /*检查是否支持APM*/
In.x.bx = 0x0000;
int86(0x15,&In,&Out);
if( Out.x.cflag != 0)
{
printf("No APM!\n");
exit(0);
}

In.x.ax = 0x5301; /*连接到APM*/
In.x.bx = 0x0000;
int86(0x15,&In,&Out);
if( (Out.x.cflag!=0) && (Out.h.ah!=0x02))
{
printf("Connecting error!\n");
exit(0);
}

In.x.ax = 0x530e; /*通知APM所使用的版本为1.2*/
In.x.cx = 0x0102;
int86(0x15,&In,&Out);
if( (Out.x.cflag != 0)
{
printf("Ver error!\n");
exit(0);
}

In.x.ax = 0x5307; /*实现关机*/
In.x.bx = 0x0001;
In.x.cx = 0x0003;
int86(0x15,&In,&Out);
if( (Out.x.cflag != 0)
{
printf("Shutdown error!\n");
exit(0);
}
}
这个是DOS系统的~
windows系统是需要api函数就好啦~
查msdn好啦~

⑨ 谁会用C语言编写自动关机程序

将下面代码存为vbs文件,如:shutdown.vbs,然后双击或在文件上点右键选择以命令提示打开,如果到了你设置重启的时候,系统会出现关机的对话框。直接下面代码程序会出现关机的对话框,最后的回车注释掉了,正常使用时,请去掉注释符。以下代码在window 2000 下通过。'定时关机或重启的脚本,在windows 2000下通过' http://www.51windows.net' code by haiwa 2005-11-7dim ActionIDActionID = 1 '0注销,1关机,2重启,ActionTime = "2005-11-7 13:42:30" '关机或重启时间function ShutDown() dim objShell Set objShell = WScript.CreateObject("Wscript.Shell") dim Application set Application = CreateObject("Shell.Application.1") Application.ShutdownWindows() dim upi for upi = 0 to 4 WScript.Sleep(50) objShell.sendKeys("{UP}") next For upi = 1 to ActionID WScript.Sleep(50) objShell.sendKeys("{DOWN}") next '使用时,请把下行的注释符去掉 'objShell.sendKeys("{ENTER}")end functionWhile true if DateDiff("s", Now, ActionTime) < 0 then ShutDown() end if WScript.Sleep(5*1000)wend