系统关闭条件 [英] System shutdown condition
本文介绍了系统关闭条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果要在达到条件后关闭系统,我想知道if循环中的条件是什么.
我的意思是如果我的if循环看起来像这样..
if(时间> 8pm ||系统关闭)
那么我应该写些什么代替系统关闭?
I want to know what should be the condition in my if loop if i want to shutdown my system if the condition is reached.
I mean if my if loop looks like this..
if(time>8pm || system shutdown)
then what should i write in place of system shutdown?
推荐答案
System.Diagnostics.Process.Start("shutdown","/s/t 0");
它可能对您有帮助.
问候,
shefeek
Hi,
System.Diagnostics.Process.Start("shutdown", "/s /t 0");
It may helps you.
Regards,
shefeek
System.Diagnostics.Process.Start("shutdown -s");
在代码中将InteropServices
命名空间用作
UseInteropServices
namespace in your code as
using System.Runtime.InteropServices;
然后声明
then declare
[DllImport("user32.dll")]
public static extern int ExitWindowsEx(int uFlags, int dwReason);
然后将ExitWindowEx与适当的参数一起用作要关闭系统的事件
and then use ExitWindowEx with appropriate parameter as event where you want to shutdown your system
ExitWindowsEx(1, 0);
这篇关于系统关闭条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文