========================================================================
Add below code in your project.
using Microsoft.Win32;
private void Form1_Load(object sender, EventArgs e)
{
SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(SystemEvents_PowerModeChanged);
}
void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
if (e.Mode.Equals(PowerModes.Resume))
{
//Do what you want when system back.
}
}
System will occur the PowerModeChanged event when system back from Sleep or Hibernate. We can use this event to do what we want.
中文
========================================================================
在程式中增加以下程式碼:
using Microsoft.Win32;
private void Form1_Load(object sender, EventArgs e)
{
SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(SystemEvents_PowerModeChanged);
}
void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
if (e.Mode.Equals(PowerModes.Resume))
{
//Do what you want when system back.
}
}
當系統從 S3 或 S4 恢復時,會觸發 PowerModeChange event,因此就能完成所想對應的事情。
沒有留言:
張貼留言