|
using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;//
namespace Shutdown
{
public partial class Form1 : Form
{
int choice = 0;
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void Submit_Click(object sender, EventArgs e)
{
string Args = "shutdown";
int time = Convert.ToInt32(textBox1.Text);
if (time >= 0)
{
switch (choice)
{
case 0:
MessageBox.Show("您未选择接下来的动作!请单击单选框!");
break;
case 1:
MessageBox.Show("您的计算机将于" + time + "秒后关机!");
Args = "shutdown -s -t " + Convert.ToString(time);
Process.Start("cmd.exe", Args);
break;
case 2:
MessageBox.Show("您的计算机将于" + time + "秒后重新启动!");
Args = "shutdown -r -t " + Convert.ToString(time);
Process.Start("cmd.exe", Args);
break;
case 3:
MessageBox.Show("您的计算机将于" + time + "秒后注销当前账户!");
Args = "shutdown -l -t " + Convert.ToString(time);
Process.Start("cmd.exe", Args);
break;
}
}
else
{
MessageBox.Show("输入字符非法!");
}
}
private void radioButton1_CheckedChanged(object sender, EventArgs e)
{
choice = 1;
}
private void radioButton2_CheckedChanged(object sender, EventArgs e)
{
choice = 2;
}
private void radioButton3_CheckedChanged(object sender, EventArgs e)
{
choice = 3;
}
private void About_Click(object sender, EventArgs e)
{
MessageBox.Show("软件版本:ver 14309.9.20"
+"\n作者:MarvelKing"
+"\n功能:实现自定义关机、重启与注销!");
}
private void Cancel_Click(object sender, EventArgs e)
{
textBox1.Text = "";
choice = 0;
}
}
}
|
|