The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: elmo on March 26, 2011, 10:50:04 AM

Title: battery power percentage
Post by: elmo on March 26, 2011, 10:50:04 AM
I have a laptop.
I use WinXP.

If my laptop battery almost empty, there will be a notification "Low battery" on the taskbar.
I had searched a code in this forum about how to do it. But I found nothing.

So the problem is: how to get ampere/volt/vendor of battery installed in my laptop with MASM code?

Would you like to give me a clue?
Thank you.
Make program with MASM is very interesting. :U
Title: Re: battery power percentage
Post by: oex on March 26, 2011, 10:58:24 AM
It depends on your hardware as to how much information you will get.... As far as I remember some laptops will *only* tell you when you have a few percentage points left....

GetSystemPowerStatus (http://msdn.microsoft.com/en-us/library/aa372693(v=vs.85).aspx)
Title: Re: battery power percentage
Post by: elmo on March 26, 2011, 11:05:49 AM
thanks for quick reply!

this link will help solve my problem
http://www.asmcommunity.net/board/index.php?topic=29838.0

i want to learn it first!
many thanks for the information oex!
Title: Re: battery power percentage
Post by: elmo on March 26, 2011, 11:16:09 AM
ok this is the solution

      invoke GetSystemPowerStatus,ADDR SPS
      .if SPS.BatteryLifeTime == -1
         invoke MessageBox,hWin,SADD("Batery almost empty. Prepare to shutdown"),SADD("info"),0
      .else
         invoke MessageBox,hWin,SADD("Batery not empty"),SADD("info"),0
      .endif

:cheekygreen: :dance:
Title: Re: battery power percentage
Post by: elmo on March 26, 2011, 12:57:32 PM
 :cheekygreen: