[ DllImport("user32") ]public static extern long ExitWindowsEx(long uFlags, long dwReserved ) ;
const int SHUTDOWN = 1 ;
long dwReserved ;
ExitWindowsEx(SHUTDOWN, dwReserved);

解决方案 »

  1.   

    设置以后用Timer来控制就行啦
      

  2.   

    public class Test
    {
     public static void Main()
     {
      
      ProcessStartInfo startinfo = new ProcessStartInfo();   
      startinfo.UseShellExecute = false;
      startinfo.RedirectStandardOutput = true;
      startinfo.CreateNoWindow = false;
      startinfo.FileName = "shutdown.exe";
      startinfo.Arguments = "/r";
    //set other parameter can realize shutdown......
      Process.Start(startinfo);
     }

      

  3.   

    using System;using System.Diagnostics;
    namespace CloseComputer
    {
    /// <summary>
    /// Summary description for Class1.
    /// </summary>
    class Class1
    {
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main(string[] args)
    {
    //
    // TODO: Add code to start application here
    ProcessStartInfo startinfo = new ProcessStartInfo();   
    startinfo.UseShellExecute = false;
    startinfo.RedirectStandardOutput = true;
    startinfo.CreateNoWindow = false;
    startinfo.FileName = "shutdown.exe";
    startinfo.Arguments = "/r";
    //set other parameter can realize shutdown......
    Process.Start(startinfo); }
    }
    }
    出現以下錯誤,誰能解一下:無法處理的例外狀況: System.ComponentModel.Win32Exception: 系統找不到指定的檔案。   at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startIn
    fo)
       at System.Diagnostics.Process.Start()
       at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
       at CloseComputer.Class1.Main(String[] args) in d:\c#formytry\closecomputer\cl
    osecomputer\closecomputer\class1.cs:line 28