C# 窗口实现定时关机系统
来源:互联网 发布:模拟经营类游戏 知乎 编辑:程序博客网 时间:2024/06/08 19:45
看一下运行之后的效果图
看代码
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 ShutDoneWindows{ public partial class ShutDone : Form { public ShutDone() { InitializeComponent(); } private void menuItemExit_Click(object sender, EventArgs e) { Application.Exit(); } private void ShutDone_Load(object sender, EventArgs e) { this.timer1.Start(); DateTime DT = System.DateTime.Now; string dt = System.DateTime.Now.ToString(); txtDatatime.Text = dt; } private void btnHide_Click(object sender, EventArgs e) { this.Hide(); this.notifyIcon1.Visible = true; } private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e) { this.Visible = true; this.WindowState = FormWindowState.Normal; this.notifyIcon1.Visible = false; } private void btnShutDone_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start("cmd.exe", "/cshutdown -s -t 0"); } private void btnReLogin_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start("cmd.exe", "/logoff 0"); } private void btnReBoot_Click(object sender, EventArgs e) { System.Diagnostics.Process.Start("cmd.exe", "/shutdown -r 0"); } private void timer1_Tick(object sender, EventArgs e) { DateTime objDatetime = System.DateTime.Now; string cData = objDatetime.ToLongDateString(); string cTime = objDatetime.ToLongTimeString(); this.txtDatatime.Text = cData + "" + cTime; if (this.chkStrat.Checked == true) { int Y = this.dtpCurrentDate.Value.Year; int M = this.dtpCurrentDate.Value.Month; int D = this.dtpCurrentDate.Value.Day; int H = this.dtpCurrentTime.Value.Hour; int Min = this.dtpCurrentTime.Value.Minute; int S = this.dtpCurrentTime.Value.Second; objDatetime = new DateTime(Y, M, D, H, Min, S); System.TimeSpan remain = objDatetime - System.DateTime.Now; double time = remain.TotalSeconds; if (time < 0) { this.chkStrat.Checked = false; MessageBox.Show("设定的定时时间必须大于当前时间"); } else { if (time < 60 && this.rbtnOneMinute.Checked == true) { AwokeForm aw = new AwokeForm(); this.timer1.Stop(); this.Hide(); aw.Show(); } if (time < 0 && this.rbtnNone.Checked == true) { System.Diagnostics.Process.Start("cmd.exe", "/cshutdown -s -t 0"); } } } } private void chkStrat_CheckedChanged(object sender, EventArgs e) { } private void rbtnOneMinute_CheckedChanged(object sender, EventArgs e) { } private void rbtnNone_CheckedChanged(object sender, EventArgs e) { } }}
窗口提醒的代码!
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 ShutDoneWindows{ public partial class AwokeForm : Form { public AwokeForm() { InitializeComponent(); } private void btnCancel_Click(object sender, EventArgs e) { timer1.Stop(); this.Close(); } private void AwokeForm_Load(object sender, EventArgs e) { this.timer1.Start(); this.lblMessage.Text = "距离当前关机还有" +60+ "秒"; } int max = 60; private void timer1_Tick(object sender, EventArgs e) { this.max = max - 1; if (this.max == 0) { System.Diagnostics.Process.Start("cmd.exe", "/cshutdown -s -t 0"); this.timer1.Stop(); } else { this.lblMessage.Text = "距离当前关机还有" + this.max.ToString() + "秒"; } } }}
0 0
- C# 窗口实现定时关机系统
- c#实现定时关机
- C#定时关机注销(窗口)
- win7系统实现定时关机功能
- 系统定时关机命令
- xp系统定时关机
- linux系统定时关机
- windows系统定时关机
- 基于C#的Windows定时关机系统的设计
- 如何实现定时关机
- 程序实现定时关机
- Java实现定时关机
- VBS实现定时关机
- 定时关机的实现
- java实现定时关机
- C#操作电脑定时关机
- 浅谈系统的定时关机
- 定时关机,适用于windows系统
- 1027. 打印沙漏(20)
- 字符串逆置算法
- [Android Studio 权威教程]多渠道打包和一键完成(全部产品)打包并签名
- ArcGIS Server 10.1找回登录用户名和重置密码
- 快速排序
- C# 窗口实现定时关机系统
- 1028. 人口普查(20)
- 怎么进入 BAT 的研发部门?
- Square Coins 1398 (母函数)
- C++之容器---vector
- 事件(C# 编程指南)
- Ubuntu12.04启动后无法进入图形界面的解决方法
- poj 1426 Find The Multiple 简单搜索
- 2015多校联合第六场 hdu5373 The shortest problem 水