-
关注公众号
防丢失不迷路
有时候自己在后台下载东西,
自己要等它下载完才能关机,所以定时工具很重要
这样子,就可以让电脑自己去熬夜了
希望对你有帮助
图片示例->C# Win framework
代码示例(注意控件哦)
[ttreply]
using System;
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;
namespace 定时关机
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
//加背景图
//this.BackgroundImage = Image.FromFile(@"D:\电脑壁纸\Picture\5.jpg");
}
//确定按钮
private void button2_Click(object sender, EventArgs e)
{
try
{
//立即重启
if (radioButton_Restar2.Checked)
{
//美化点
DialogResult dr = MessageBox.Show("是否立即重启?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
if (dr == DialogResult.OK)
{
System.Diagnostics.Process.Start("shutdown.exe", "-r -f -t 0");
}
}
//立即关机
else if (radioButton_Shutdown2.Checked)
{
//美化点
DialogResult dr = MessageBox.Show("是否立即关机?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
if (dr == DialogResult.OK)
{
System.Diagnostics.Process.Start("shutdown.exe", "-s -f -t 0");
}
}
//立即注销
else if (radioButton_Cancellation2.Checked)
{
//美化点
DialogResult dr = MessageBox.Show("是否立即注销?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
if (dr == DialogResult.OK)
{
System.Diagnostics.Process.Start("shutdown.exe", "-l"); ;
}
}
//读取文本框的值触发定时
else
{
//将时间转为数字
int m_Hour = Convert.ToInt32(textBox1.Text);
int m_Min = Convert.ToInt32(textBox2.Text);
int m_Second = Convert.ToInt32(textBox3.Text);
int m_Time = m_Hour * 3600 * 1000 + m_Min * 60 * 1000 + m_Second * 1000;
//开始倒计时
timer1.Enabled = true;
timer1.Interval = m_Time;
//美化点
DialogResult dr = MessageBox.Show("定时开启!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
if (dr == DialogResult.OK)
{
}
}
}
catch
{
//MessageBox.Show("输入有误");
//美化点
DialogResult dr = MessageBox.Show("输入有误,请重新输入", "提⽰", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (dr == DialogResult.OK)
{
}
}
}
private void timer1_Tick(object sender, EventArgs e)
{
/*--------------------
功能实现:
根据各按钮执行各功能
---------------------*/
//重启
if (radioButton_Restar1.Checked)
{
System.Diagnostics.Process.Start("shutdown.exe", "-r -f -t 0");
}
if (radioButton_Shutdown1.Checked)
{
System.Diagnostics.Process.Start("shutdown.exe", "-s -f -t 0");
}
if (radioButton_Cancellation1.Checked)
{
System.Diagnostics.Process.Start("shutdown.exe", "-l");
}
}
// 取消 进程
private void button1_Click(object sender, EventArgs e)
{
timer1.Enabled = false;
//MessageBox.Show("进程已取消");
//美化点
DialogResult dr = MessageBox.Show("进程已取消!", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
if (dr == DialogResult.OK)
{
System.Diagnostics.Process.Start("shutdown.exe", "-a");
}
}
// 关于 按钮
private void button5_Click(object sender, EventArgs e)
{
//MessageBox.Show("———————感谢支持———————\n创作者:一路狂奔的乌龟\n联系QQ:75156591\n");
//美化点
DialogResult dr = MessageBox.Show("创作者:一路狂奔的乌龟\n联系QQ:75156591\n", "感谢支持", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
if (dr == DialogResult.OK)
{
}
}
// 退出 按钮
private void button6_Click(object sender, EventArgs e)
{
//美化点
DialogResult dr = MessageBox.Show("退出?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation);
if (dr == DialogResult.OK)
{
Application.Exit();
}
}
}
}
[/ttreply]
下载地址:
关注公众号
防丢失不迷路
紧急通知!
由于运营商拦截,目前江苏部分地区打不开
新地址更换通知将在公众号发布
为防止大家找不到地址还请关注公众号第一时间获取
最新资源交流QQ群:935733529