admin管理员组

文章数量:1532473

2024年3月6日发(作者:)

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;

();

();

}

}

}

附上运行界面

本文标签: 关机控件方法程序按钮