C# .NET: How to check if we're running on battery?

后端 未结 6 1899
既然无缘
既然无缘 2020-12-08 00:41

i want to be a good developer citizen, pay my taxes, and disable things if we\'re running over Remote Desktop, or running on battery.

If we\'re running over remote d

6条回答
  •  心在旅途
    2020-12-08 01:22

    Powerlord's answer doesn't seem to work, probably because it was answered in 2008.

    Here is a version that worked for me:

    Boolean x = (System.Windows.SystemParameters.PowerLineStatus == System.Windows.PowerLineStatus.Offline);
    

提交回复
热议问题