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/