admin 管理员组文章数量: 1086019
2024年4月29日发(作者:ahref标签怎么不显示下划线)
using System;
using c;
using entModel;
using ;
using g;
using ;
using ;
using ;
using pServices;
using stics;
namespace ShutDownComputer
{
public partial class MainForm : Form
{
public MainForm()
{
InitializeComponent();
al = 1000;
+=new EventHandler(t_Tick);
();
}
Timer t = new Timer();
void t_Tick(object sender, EventArgs e)
{
= ng();
}
[DllImport("", EntryPoint = "ExitWindowsEx", CharSet = )]
private static extern int ExitWindowsEx(int uFlags,int dwReserved);
private void 注销ToolStripMenuItem_Click(object sender, EventArgs e)
{
ExitWindowsEx(0,0);
}
//定义关机方法
private void ShutDown()
{
Process myProcess = new Process();
me = "";
llExecute = false;
ctStandardInput = true;
ctStandardOutput = true;
ctStandardError = true;
NoWindow = true;
(); //启动进程
ine("shutdown -s -t 0");
}
//定义最小化方法
private void HideMainForm()
{
();
}
//定义显示方法
private void ShowMainForm()
{
();
State = ;
te();
}
private void 关机ToolStripMenuItem_Click(object sender, EventArgs e)
{
ShutDown();//调用关机方法
}
private void 关机重启ToolStripMenuItem_Click(object sender, EventArgs e)
{
Process myProcess = new Process();
me = "";
llExecute = false;
ctStandardInput = true;
ctStandardOutput = true;
ctStandardError = true;
NoWindow = true;
();
ine("shutdown -r -t 0");
}
private void 退出程序ToolStripMenuItem1_Click(object sender, EventArgs e)
{
();
();
}
private void 重新设定ToolStripMenuItem_Click(object sender, EventArgs e)
{
= 1;
= 1;
= 30;
();
();
}
private void 计时开始ToolStripMenuItem_Click(object sender, EventArgs e)
{
al = 1000;
+= new EventHandler(timer_Tick);
();
HideMainForm();
}
Timer timer = new Timer();
void timer_Tick(object sender, EventArgs e)
{
if ( == 0)
{
if ( == 0)
{
if ( == 0)
{
();
ShutDown();
}
else
{
--;
= 60;
}
}
else
{
--;
= 59;
}
}
else
{
--;
}
}
private void 版本信息ToolStripMenuItem_Click(object sender, EventArgs e)
{
("软件名称:定时关机工具n开发环境:Microsoft Visual Studio 2010n版本
号:H4GRG68X82 (*^__^*)……");
}
private void 隐藏窗体ToolStripMenuItem_Click(object sender, EventArgs e)
{
HideMainForm();
}
private void notifyIcon_MouseDoubleClick(object sender, MouseEventArgs e)
{
if (State == )
{
State = zed;
HideMainForm();
}
else if (State == zed)
{
ShowMainForm();
}
}
//点击最小化按钮时,最小化到托盘
private void MainForm_SizeChanged(object sender, EventArgs e)
{
if (State == zed)
{
HideMainForm();
}
}
//以下是为NotifyIcon控件添加的ContextMenuStrip控件的右键按钮事件
private void menuItem_Show_Click(object sender, EventArgs e)
{
ShowMainForm();
}
private void menuItem_Hide_Click(object sender, EventArgs e)
{
HideMainForm();
}
private void menuItem_Exit_Click(object sender, EventArgs e)
{
e = false;
();
();
}
}
}
附上运行界面
版权声明:本文标题:定时关机小程序C#源代码 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/b/1714321438a675291.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论