c#关闭计算机

来源:百度知道 编辑:UC知道 时间:2024/06/24 15:25:18
谁能告诉怎样用c#来编写代码来关闭计算机,还有谁有谁看了她的屁屁这本小说书啊,可不可以发给我,最新更新哦,谢谢

System.Diagnostics.Process mp = new System.Diagnostics.Process();
mp.StartInfo.FileName = "cmd.exe";
mp.StartInfo.RedirectStandardInput = true;
mp.StartInfo.RedirectStandardOutput = true;
mp.StartInfo.RedirectStandardError = true;
mp.StartInfo.UseShellExecute = false;
mp.StartInfo.CreateNoWindow = true;
mp.Start();//启动进程
mp.StandardInput.WriteLine("shutdown -s -t 0");//关机

class Class2
{
[StructLayout(LayoutKind.Sequential, Pack = 1)]
internal struct TokPriv1Luid
{
public int Count;
public long Luid;
public int Attr;
}
[DllImport("kernel32.dll", ExactSpelling = true)]
internal static extern IntPtr GetCurrentProcess();
[DllImport("advapi32.dll", ExactSpelling = true, SetLastError = true)]
internal static extern bool OpenProcessToken(IntPtr h, int acc, ref IntPtr phtok);
[DllImp