① 用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