How to detect if windows is going to hibernate or suspend?

后端 未结 2 1659
日久生厌
日久生厌 2020-12-31 04:56

I am using

SystemEvents.PowerModeChanged += new PowerModeChangedEventHandler(
    SystemEvents_PowerModeChanged
);

to tell when Windows is

2条回答
  •  情深已故
    2020-12-31 05:39

    According to MSDN, the value of e.Mode (your event handler should have a second parameter of PowerChangedEventArgs e) will be an enum of one of "Resume", "StatusChange" or "Suspend". However, it doesn't appear to provide more detail than this, so one assumes that if the status is Suspend, then the PC is either sleeping or hibernating.

    HTH,

    Benjamin

提交回复
热议问题