using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
DateTime startTime, endTime;
private void timer1_Tick_1(object sender, EventArgs e)
{
if (DateTime.Now.ToString() == endTime.ToString())
{
timer1.Stop();
MessageBox.Show("開始時間:" + startTime + "\n現在時間:" + endTime.ToString() + "\n該關機了");
}
}
private void Form1_Load(object sender, EventArgs e)
{
startTime = DateTime.Now;
endTime = startTime.AddMinutes(55);//電腦打算用多久,請以分鐘為單位(預設55分鐘)
}
}
}
ps.需配合windows的自動排程在一開機的時候啟用,未來打算改成在背景執行作業