[DllImport("user32")]
public static extern long SetWindowPos(long hwnd, long hWndInsertAfter, long X, long y, long cx, long cy, long wFlagslong)
[DllImport("user32")]
public static extern long ExitWindowsEx(long uFlags, long dwReserved)
[DllImport("shell32")]
public static extern long ShellAbout(long uFlags, long dwReserved)
public void DoExitWin(int flg)
{
bool ok
TokPriv1Luid tp
IntPtr hproc = GetCurrentProcess()
IntPtr htok = IntPtr.Zero
ok = OpenProcessToken(hproc, TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, ref htok)
tp.Count = 1
tp.Luid = 0
tp.Attr = SE_PRIVILEGE_ENABLED
ok = LookupPrivilegeValue(null, SE_SHUTDOWN_NAME, ref tp.Luid)
ok = AdjustTokenPrivileges(htok, false, ref tp, 0, IntPtr.Zero, IntPtr.Zero)
ok = ExitWindowsEx(flg, 0)
}
//#include "stdafx.h"#include "stdio.h"
#include "string.h"
#include "stdlib.h"
int print()
{
printf(" ╪╪╪╪╪╪╧╧╧╧╧╧╧╧╪╪╪╪╪╪\n")
printf("╔═══╧╧ C语言 关机程序 ╧╧═══╗\n")
printf("║※1.实现10分钟内的定时关闭计算机 ║\n")
printf("║※2.立即关闭计算机 ║\n")
printf("║※3.注销计算机 ║\n")
printf("║※0.退出系统 ║\n")
printf("╚═══════════════════╝\n")
return 0
}
void main()
{
system("title C语言关机程序")//设置cmd窗口标题
system("mode con cols=48 lines=25")//窗口宽度高度
system("color 0B")
system("date /T")
system("TIME /T")
char cmd[20]="shutdown -s -t "
char t[5]="0"
print()
int c
scanf("%d",&c)
getchar()
switch(c)
{
case 1:printf("您想在多少秒后自动关闭计算机?(0~600)\n")scanf("%s",t)system(strcat(cmd,t))break
case 2:system("shutdown -p")break
case 3:system("shutdown -l")break
case 0:break
default:printf("Error!\n")
}
system("pause")
exit(0)
}
可以的,给以下代码已经编译运行确认了(害得我关了一次机!)#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
procedures\n")
printf("
Watermelon
production\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
procedures
Watermelon
production
Please
enter
your
desired
automatic
shutdown
of
time:12:29
新加了一项作业,其作业
ID
=
1
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)