Community discussion forum

Laptop Battery Charge monitoring ... need help

Tags: vb6 India
  • 4 years ago

    Hello to all Forum Members,


    I'm looking for a Program code or Link or anything which can give me a hint regarding ...


    "How to show the battery charge level for two batteries on a Laptop?"


    I'm working on a Battery Level Indication Application (somewhat similar to Windows' Battery Indicator, which you will find in System Tray). In that application, I need to provide a support for indication of all the available batteries and then showing the charge of each battery. If you have worked on Laptop with XP installed on it. You must have used the Windows' Battery Indicator. In that, they have given a option button to show the charge of all the batteries available.


    Please let me know if you have any information regarding the same. Any Visual Basic Code or any COM control or website link which will give information on this issue ... really anything which you feel will be helpful for me.


    Waiting for your reply ...


    Ruturaj.

  • 4 years ago

    Ruturaj


    SysInfo control may well serve your requirements
    Look Here


    Trevor

  • 4 years ago

    Quote:
    [1]Posted by TrevorG on 18 Sep 2005 02:10 PM[/1]
    Ruturaj


    SysInfo control may well serve your requirements
    Look Here


    Trevor



    Thanks Trevor. Actually, I have written the code which does it all without any external OCX like SysInfo. I have used GetSystemPowerStatus API that gives me all the information regarding battery charge. However, I suspect it gives the information about only one battery found in very first battery slot in Device Map.


    I searched on MSDN and I have got some valuable information about the battery and other stuff which I was not knowing at all. There are few Interfaces which are to be implemented on the Device Handle. There is IOCTLBATTERYQUERY_INFORMATION which needs to be implemented with DeviceIoControl API. But it's not that straight.


    What I have understood is that ... first I need to enumerate all the Devices available using SetupDiGetClassDevs and then filter out Battery Device classes out of those all. Then SetupDiEnumDeviceInterfaces to get the Battery evice System name which later to be used with CreateFile to obtain the Device Handle. Then passing this Device Handle to DeviceIoControl through IOCTLBATTERYQUERY_INFORMATION to obtain the information regarding each battery. There is also something called Device Unique ID which I don't know for what sake of goodness it is!


    Uh! I think I should go for PhD in this topic!


    Please let me know if there is some easy method. Or any ready to use code will absolutely make me to feel in heaven! Please let me know if my strategy is wrong and there is some other simple way of getting the information regarding ...


    [1] Whether there are more than one batteries available?
    [2] If yes, then all the information as returned by SysInfo or GetSystemPowerStatus API for each battery unit.


    Thanks in advanced.


    Ruturaj.

Post a reply

Enter your message below

Sign in or Join us (it's free).

Want to stay in touch with what's going on? Follow us on twitter!