Find Out PC & Laptop Power Status From in Battery Or Charging Using Asp.Net C#

Find Out PC & Laptop Power Status  in  Battery Or Charging 


Your PC or Laptop Charging From Battery or Charging in Asp.Net C#.

                                      DEMO
Charge Control Check

                       C# CODING

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Management;
using System.Runtime.InteropServices;
using System.Windows.Forms;

public partial class Battery : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        PowerLineStatus status = SystemInformation.PowerStatus.PowerLineStatus;
        if (status == PowerLineStatus.Offline)
        {
            MessageBox.Show("Running on Battery");
        }
        else
        {
            MessageBox.Show("Running on Power");
        }
              
    }

}


First - Add New Web Form - Add Button From 

Toolbox





Next - Solution Explorer - Add - Add Reference 





Next - Add - System.Windows.Form - OK






Next - Add Namespaces - Add Charge Control  Status Checker






Next - Run[F5] - Click Button - Charge Control Check



0 comments:

Post a Comment