Archive for October, 2013

Finding power source of laptop in c#

Here i am going to write a simple process about how to detect whether your laptop running on battery or current. For this i create a simple windows form application.

A button is placed on the form. I just want to show the system so nothing added without this.


Double click on the button and on its click event write these codes:

private void button1_Click(object sender, EventArgs e)

PowerLineStatus status = SystemInformation.PowerStatus.PowerLineStatus;

if (status == PowerLineStatus.Offline)
MessageBox.Show(“Running on Battery”);
MessageBox.Show(“Running on Power”);



Its done. So simple. Try this.

Fun with code.


1 Comment