Re:c#实现关机,注销,重启源代码 另一份代码 using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.Management; using System.Runtime.InteropServices; //加入此名字间是为了引用Windows API 来实现关机 namespace RebootComputer { public class Form1 : System.Windows.Forms.Form { //---------------这部分都是控件-------- private System.Windows.Forms.Button Reboot; private System.Windows.Forms.Button ShutDown; private System.ComponentModel.Container components = null; private System.Windows.Forms.Button Exit; //--------------------------------------------------------- private ManagementObjectSearcher obj ; //-----------------程序初始化---------------- public Form1() { InitializeComponent(); } //-----------------------程序释放---------------------- protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } //-------------------------初始化---------------------- private void InitializeComponent() { this.Reboot = new System.Windows.Forms.Button(); this.ShutDown = new System.Windows.Forms.Button(); this.Exit = new System.Windows.Forms.Button(); this.SuspendLayout(); // // Reboot // this.Reboot.Location = new System.Drawing.Point(16, 16); this.Reboot.Name = "Reboot"; this.Reboot.TabIndex = 0; this.Reboot.Text = "重启"; this.Reboot.Click += new System.EventHandler(this.Reboot_Click); // // ShutDown // this.ShutDown.Location = new System.Drawing.Point(112, 16); this.ShutDown.Name = "ShutDown"; this.ShutDown.TabIndex = 1; this.ShutDown.Text = "关机"; this.ShutDown.Click += new System.EventHandler(this.ShutDown_Click); // // Exit // this.Exit.Location = new System.Drawing.Point(216, 16); this.Exit.Name = "Exit"; this.Exit.TabIndex = ...