Battery time remaining 71,582,788 minutes

Source: Internet
Author: User

Using WMI to view the rest of your laptop battery, the result was 71,582,788 minutes, and the first feeling was that the relevant code was wrong.

ManagementObjectSearcher s = new ManagementObjectSearcher ("SELECT * from Win32_Battery");   
Managementobjectcollection m = S.get ();   
foreach (ManagementObject mo in M)   
{   
    Console.WriteLine (mo["EstimatedRunTime"]. ToString () + "Minutes");   
}

Check a few times, did not find the problem, and search the internet for similar code, but also the wording.

After being bothered for a while, try unplugging the power cord from the laptop and starting the program again, this time it's not the 71582788 value.

So the conclusion is that the code can only get the correct results without using an external power supply.

So why do you get 71582788 such odd numbers when you're using an external power supply?

In fact, the value obtained from the EstimatedRunTime attribute is in minutes. The 71,582,788-minute conversion to seconds is 4294967296, which is 2^32. The maximum value for a 32-bit second counter is this value.

In other words, because plug in the case of power, theoretically notebook can continue to use, so estimatedruntime use 71,582,788 minutes to express the meaning can be unlimited use.

The above is purely my guess.

It should be added that even if the power cord is unplugged, the final result may not be correct.

Can run more than a few times this program, it is not difficult to find that each of the results are inconsistent, and the difference is very large, or even error in more than one hours.

But this is a normal result. Because the remaining power of the notebook shows that this is the way it is, the system's own detection procedures have the same problem. For the moment, this should be a problem that cannot be solved for the time being.

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/extra/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.