C#如何监测电脑将要重启? C#如何监测电脑将要重启?C# 电脑重启 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Microsoft.Win32.SystemEvents.SessionEnding += ... 谢谢了 找到方法了这是MSDN给的实例代码:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.Forms;namespace WindowsApplication1{ public partial class Form1 : Form { private static int WM_QUEYENDSESSION = 0x11; private static bool systemShutdown = false; protected override void WndProc(ref System.Windows.Forms.Message m) { if (m.Msg==WM_QUEYENDSESSION) { MessageBox.Show("queryendsession:这是一个注销或重新启动,关机,"); systemShutdown = true; } base.WndProc(ref m); } public Form1() { InitializeComponent(); } private void Form1_FormClosing(object sender, FormClosingEventArgs e) { if (systemShutdown) { systemShutdown = false; if (DialogResult.Yes == MessageBox.Show("系统信息", "你想登出前保存你的工作?", MessageBoxButtons.YesNo)) { e.Cancel = true; } else { e.Cancel = false; } } } }} 简单代码示例,为什么提示红色部分没有赋值? 迷惑中...不理解回调接口,委托,不知道解决了什么问题,用意何在,不懂!!求解! 在windows程序中,什么能实现Session的功能? BS结构,菜鸟级问题 请哪个兄弟高手能够提供一个好的文本编辑器及示例源码一份. 如何用c#制作ie插件 关于C#的登陆主界面的问题 大神们,求投票作弊软件制作思路或直接给个软件 求助:如何用WPF实现界面左右滑动效果? 多线程的问题,哪位高手帮解决以下阿 ? listview 项文本碰到运算符就会换行怎么破?? winform模拟登录discuz网站 发帖
这是MSDN给的实例代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace WindowsApplication1
{
public partial class Form1 : Form
{
private static int WM_QUEYENDSESSION = 0x11;
private static bool systemShutdown = false; protected override void WndProc(ref System.Windows.Forms.Message m)
{
if (m.Msg==WM_QUEYENDSESSION)
{
MessageBox.Show("queryendsession:这是一个注销或重新启动,关机,");
systemShutdown = true;
}
base.WndProc(ref m);
} public Form1()
{
InitializeComponent();
} private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
if (systemShutdown)
{
systemShutdown = false;
if (DialogResult.Yes == MessageBox.Show("系统信息", "你想登出前保存你的工作?",
MessageBoxButtons.YesNo))
{
e.Cancel = true;
}
else
{
e.Cancel = false;
}
}
}
}
}