【免费分享】自制定时关机、重启、注销工具 Windows 办公学习 上传/下载 休闲娱乐

游戏/软件 2022-08-24 07:59   4032 9

有时候自己在后台下载东西,

自己要等它下载完才能关机,所以定时工具很重要

这样子,就可以让电脑自己去熬夜了

希望对你有帮助

 

 

 

图片示例->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]

下载地址:

最新回复 (9)
  • yamha
    2022-08-24 10:43
    大佬nb
  • roninzhou
    2022-08-24 11:27
    好人一生平安
  • hb7812
    2022-08-24 13:39
    感谢盘主发这么好的资源
  • 酷乐
    2022-09-19 18:31
    楼主太厉害了!这个资源都能找到,辛苦了!
  • zedesr
    2022-12-16 08:29
    good!3q!
  • 阳光少年
    2022-12-17 04:14
    good!3q!
  • 谢谢你,分享侠
  • XINGHE
    2023-11-26 11:18
    太棒了,感谢楼主分享
    • 网盘资源社-免费优质云盘网盘资源分享社区论坛!
      11
        立即登录 免费注册

关注公众号
防丢失不迷路