locked
Battery Status RRS feed

  • Question

  • i wanna know how to get remaining time of battery life time...

    I cant Do it with this :- SystemInformations.PowerStatus

    So If Anybody can help me.... Thanks Him Very Much

    Tuesday, March 15, 2016 1:21 AM

Answers

  • You can use:
    PowerStatus Class

    SystemInformation.PowerStatus.BatteryLifeRemaining
      (Gets the approximate number of seconds of battery time remaining.)

    SystemInformation.PowerStatus.BatteryFullLifetime
      (Gets the reported full charge lifetime of the primary battery power source in seconds.)

    SystemInformation.PowerStatus.BatteryLifePercent
      (Gets the approximate amount of full battery charge remaining.)

    Regards.
    • Proposed as answer by Kristin Xie Thursday, March 24, 2016 8:08 AM
    • Marked as answer by Kristin Xie Friday, March 25, 2016 1:26 AM
    Tuesday, March 15, 2016 10:28 AM
  • Hi Great-X,

    You could use Win32_Battery Class. Hope this helps you.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Management;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                System.Management.ObjectQuery query = new ObjectQuery("Select * FROM Win32_Battery");
                ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
    
                ManagementObjectCollection collection = searcher.Get();
    
                foreach (ManagementObject mo in collection)
                {
                    foreach (PropertyData property in mo.Properties)
                    {
                        Console.WriteLine("Property {0}: Value is {1}", property.Name, property.Value);
                    }                   
                }
            }
        }
    }

    Thanks,

    Sabah Shariq

    • Proposed as answer by Kristin Xie Thursday, March 24, 2016 8:08 AM
    • Marked as answer by Kristin Xie Friday, March 25, 2016 1:26 AM
    Tuesday, March 15, 2016 11:25 AM

All replies

  • You can use:
    PowerStatus Class

    SystemInformation.PowerStatus.BatteryLifeRemaining
      (Gets the approximate number of seconds of battery time remaining.)

    SystemInformation.PowerStatus.BatteryFullLifetime
      (Gets the reported full charge lifetime of the primary battery power source in seconds.)

    SystemInformation.PowerStatus.BatteryLifePercent
      (Gets the approximate amount of full battery charge remaining.)

    Regards.
    • Proposed as answer by Kristin Xie Thursday, March 24, 2016 8:08 AM
    • Marked as answer by Kristin Xie Friday, March 25, 2016 1:26 AM
    Tuesday, March 15, 2016 10:28 AM
  • Hi Great-X,

    You could use Win32_Battery Class. Hope this helps you.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Management;
    
    namespace ConsoleApplication1
    {
        class Program
        {
            static void Main(string[] args)
            {
                System.Management.ObjectQuery query = new ObjectQuery("Select * FROM Win32_Battery");
                ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
    
                ManagementObjectCollection collection = searcher.Get();
    
                foreach (ManagementObject mo in collection)
                {
                    foreach (PropertyData property in mo.Properties)
                    {
                        Console.WriteLine("Property {0}: Value is {1}", property.Name, property.Value);
                    }                   
                }
            }
        }
    }

    Thanks,

    Sabah Shariq

    • Proposed as answer by Kristin Xie Thursday, March 24, 2016 8:08 AM
    • Marked as answer by Kristin Xie Friday, March 25, 2016 1:26 AM
    Tuesday, March 15, 2016 11:25 AM