Partager via


Updating the Battery Driver for Windows CE .NET 4.2

The Device Manager, Device.exe, loads the battery driver as a stream driver. The battery driver is no longer a built-in part of the Graphics, Windowing, and Events Subsystem (GWES). With this design, configurations that do not include GWES, such as HLBASE, can receive access to the battery application programming interfaces (APIs). This design also enables battery information to become available earlier in the boot process and enables you to support batteries that report more, or different, data than the standard APIs permit.

Applications can continue to use battery APIs without modification. However, consider the following guidelines when you use battery APIs:

  • If you are using a custom Cesysgen.bat file, rather than HLBASE or IABASE, the GWES getpower component no longer exists. Instead, you should add the battery component to the COREDLL_COMPONENTS environment variable, and you should add battdrvr to the CE_MODULES environment variable.
  • You can begin using battery APIs when the SYSTEM/BatteryAPIsReady event is signaled. This event is defined as BATTERY_API_EVENT_NAME in Battery.h.
  • The battery driver must advertise the {DD176277-CD34-4980-91EE-67DBEF3D8913} GUID, preferably in the driver's IClass subkey. This GUID is defined as BATTERY_DRIVER_CLASS in Battery.h. Drivers that advertise this interface must support IOCTLs listed in Battery.h.
  • The files for a sample null battery are located in %_WINCEROOT%\Public\Common\Oak\Drivers\Battdrvr. This driver is linked by the battdrvr Sysgen target.
  • The battery driver is divided into a model device driver (MDD) and a platform dependant driver (PDD). The library Battdrvr_lib implements the MDD and includes a sample PDD. To implement an actual PDD, implement all of the PDD entry points in Sbattif.c in your platform and link with the MDD.
  • The files for a sample battery driver are located in %_WINCEROOT\Platform\Xsc1bd\Drivers\Battdrvr.

To move an existing battery driver out of GWES from Windows CE .NET 4.1 to Windows CE .NET 4.2

  1. Add battdrvr to %_WINCEROOT%\Public\Common\Oak\Drivers\Dirs.

  2. Copy the source and header information from gwes\battery to %_WINCEROOT%\Public\Common\Oak\Drivers\Battdrvr.

  3. Copy %_WINCEROOT%\Platform\Xsc1bd\Drivers\Battdrvr\Sources, Makefile, and Battdrvr.def to %_WINCEROOT%\Public\Common\Oak\Drivers\Battdrvr.

  4. Edit the sources file as appropriate for your sources.

    For example, you should change the file name, include the path, and make further modifications. For more information about the sources file, see Sources File.

  5. To supply the new APIs expected by the MDDs, edit the battery sources.

    If the platform's battery driver contains object files that include all of the entry points currently provided by Sbattif.c in the MDD, the linker will include the platform code rather than Sbattif.obj in the final executable. In this way, you can link your own PDD with the battery driver library created in the Public directory, which serves as both a sample driver and as an MDD.

  6. Add .bib and .reg entries for the new drivers, using any of the sample platforms as a guide.

    To find examples of this, search for BATTDRVR in Platform.bib and Platform.reg.

  7. If your battery driver shares resources with any other drivers, and previously relied on the fact that GWES was loaded later than installable drivers, adjust the driver load order in the registry as appropriate.

See Also

How to Migrate a Board Support Package to Windows CE .NET 4.2

Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.