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
Here, is a little solution: using C# windows form application,
PowerStatus powerStatus = SystemInformation.PowerStatus;
if (powerStatus.PowerLineStatus == PowerLineStatus.Online)
{
MessageBox.Show("Running On Power", Convert.ToString(powerStatus.BatteryLifePercent * 100) + "%");
}
else
{
MessageBox.Show("Running On Battery", Convert.ToString(powerStatus.BatteryLifePercent * 100) + "%");
}
Hope, you got the idea, now you can use it in any way,...........