How to detect when laptop power cable has been disconnected?

前端 未结 7 2125
终归单人心
终归单人心 2020-12-05 15:53

For the umpteenth time my laptop just shut down in the middle of my game because my power cable had disconnected without me noticing it.

Now I want to write a little

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-05 16:22

    SystemEvents.PowerModeChanged. You will need to use either GetSystemPowerStatus (see link in one of the answers) or SystemInformation.PowerStatus (link is in another answer) in the handler to check what happened.

提交回复
热议问题