How do I support GetSystemPowerStatusEx?

We have a custom board with an ADC to measure battery voltage. I do not want to create a custom platform build for the VF61 but would like to implement a driver/service to support the CE GetSystemPowerStatusEx functionality–not just in our application, but for the CE 6 OS so it can support automatic sleep/shutdown based on the battery level. What is the easiest path to accomplish this? I noticed that there is a battery.dll (documented as a “dummy” module) in the Windows folder, but not BuiltIn\Battery entries in the registry. Is it as simple as adding the registry entries?

Hi,

To do this you will need to create battery driver. We include dummy driver but it only reports that system is powered by AC.

To add extra functionality you will have to add your driver. Maybe it would be easier to create a function that measures your battery and reports it back to your program?

Thank you. I was afraid of that answer but my understanding is that my driver could be loaded at startup via the battery driver registry entries and wouldn’t need to be incorporated in a custom build. Is this correct?

You can create a driver and load it at the boot if you want.

Just follow this registry settings here → Battery Driver Registry Settings (Windows CE 5.0) | Microsoft Docs
This will only load your driver and not our dummy ones.

I added implementation of read battery driver to our roadmap. Do you have any target date when you need this?

I will need it within the next month.

Hi,

You can download battery driver from here → Driver
And save to if Flashdisk\System
All you have to do is add this registry settings →

[HKEY_LOCAL_MACHINE\System\Events]
    "SYSTEM/BatteryAPIsReady"="Battery Interface APIs"

[HKEY_LOCAL_MACHINE\Drivers\BuiltIn\Battery]
   "Prefix"="BAT"
   "Dll"="battdrvr.dll"
   "Flags"=dword:8                      ; DEVFLAGS_NAKEDENTRIES
   "Order"=dword:0
   "IClass"="{DD176277-CD34-4980-91EE-67DBEF3D8913}"

After that the driver will load on boot. To communicate with driver you can use memory mapped file. You can download a sample how to use it here →
Sample

This sample shows how to update battery state to critical. You can use Microsoft documentation to find out other valid states.