using System.Windows;
using Microsoft.Win32;
namespace CatchHibernateMsg
{
/// <summary>
/// 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.
/// </summary>
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
WPF程序响应系统休眠唤醒消息
最新推荐文章于 2021-01-13 09:07:46 发布