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
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 stati