- 加粗样式
***WPF程序响应系统休眠唤醒消息## 标题
using System.Windows;using Microsoft.Win32;namespace CatchHibernateMsg{ /// /// We will catch system’s suspend and resume events by adding handlers in Microsoft.Win32.SystemEvents’s static events. /// So that when you suspend or resume your computer,it shall show a dialog to inform you. /// public partial class MainWindow : Window { SessionEndedEventHandler seeh; PowerModeChangedEventHandler pmceh; public MainWindow() { InitializeComponent(); addEventsHandlers(); } private void addEventsHandlers() { this.Closing += new System.ComponentModel.CancelEventHandler(MainWindow_Closing); seeh = new SessionEndedEventHandler(SystemEvents_SessionEnded); pmceh = new PowerModeChangedEventHandler(SystemEvents_PowerModeChanged); SystemEvents.SessionEnded += seeh; SystemEvents.PowerModeChanged += pmceh; } void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs