How can I programmatically stop a notebook battery from charging

前端 未结 10 1217
深忆病人
深忆病人 2021-02-14 19:34

There is some easily available information on finding the status of a battery, or weather it\'s charging or not. (GetSystemPowerStatus API or System.Windows.Forms.SystemInformat

10条回答
  •  难免孤独
    2021-02-14 19:51

    One of the options is to get hold of the device(I) for battery (Microsoft ACPI-Compliant Control Method Battery). Listen for PowerNotification events forever. On each notification check the PowerStatus of the battery. There are APIs for all of the above purposes in .Net and win32

    Keep the device(I) disabled as long as the powerstatus is >threshold. Enable it as soon as goes below that or when you are not on AC power (i.e. before removing AC power, your continuously monitoring software should enable that battery device - or you manually enable it).

    hmm,...this is a very buggy solution, but it can achieve what you want, although you have to be very careful.

提交回复
热议问题