Remaining battery time 71582788 minutes

Source: Internet
Author: User

I checked the remaining time of my laptop battery in WMI mode and got the result of 71582788 minutes. unexpectedly, the first thought 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 ");}

I checked several times and found no problems. I also searched for similar code on the Internet.

After being troubled for a while, I tried to unplug the power cord of my notebook and start the program again. This is not the value of 71582788.

Therefore, the conclusion is that the Code can obtain the correct result only when the external power supply is not used.

Why do we get such a strange number as 71582788 when using an external power supply?

In fact, the value obtained from the EstimatedRunTime attribute is in minutes. 71582788 minutes are converted to 4294967296 seconds, that is, 2 ^ 32. The maximum value of a 32-bit second counter is this value.

In other words, because the notebook can be used continuously in theory when the power is plugged in, EstimatedRunTime uses 71582788 minutes to indicate unlimited usage.

The above is my guess.

The final result may not be correct even if the power cord is switched out.

You can run this program several times. It is not difficult to find that the results are inconsistent each time, and the difference is large, or even the error is more than an hour.

However, this is a normal result. Because the remaining power of the notebook is originally shown in this way, the detection program of its system has the same problem. For the moment, this should be a problem that cannot be solved temporarily.

Published in my blog at the same time

Related Article

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.