How can I know when Windows is going into/out of sleep or Hibernate mode?

前端 未结 6 1175
野的像风
野的像风 2020-12-03 03:20

Is it possible to subscribe to a Windows event that fires when Windows is going into or coming out of Sleep or Hibernate state?

I need my application to be made awar

6条回答
  •  佛祖请我去吃肉
    2020-12-03 03:44

    Not sure how often you want to monitor this, but if you write a service in .NET you can override ServiceBase, set CanHandlePowerEvent to true, and then you'll be notified of power changes via the PowerBroadcastStatus enumeration.

提交回复
热议问题