Battery Driver Development Concepts (Windows CE 5.0)
The battery driver, which is loaded by the Device Manager, exposes a stream interface. The exposed stream interface provides OS designs that do not include GWES access to the battery functions. The interface also provides battery information earlier in the boot process and enables you to support batteries that report more, or different, information than the standard functions permit.
Note Ensure that the device never wakes up for the sole purpose of displaying a low-battery warning.
The following list shows the functions that the battery driver enables:
- GetSystemPowerStatusEx
- GetSystemPowerStatusEx2
- PowerPolicyNotify
- BatteryDrvrGetLevels
- BatteryDrvrSupportsChangeNotification
- BatteryGetLifeTimeInfo
- BatteryNotifyOfTimeChange
Battery PDD Interface
Battery functions are translated into Battery Driver IOCTLs and passed to the battery driver. The battery driver model device driver (MDD) then invokes internal functions that may result in platform-dependent driver (PDD) calls.
The following list shows the battery driver PDD functions:
- BatteryPDDInitialize
- BatteryPDDDeinitialize
- BatteryPDDResume
- BatteryPDDPowerHandler
- BatteryPDDGetStatus
- BatteryPDDGetLevels
- BatteryPDDSupportsChangeNotification
In addition to these functions, you can have the battery PDD receive custom IOCTLs. To enable this, you must have the PDD declare a function to process the IOCTL codes and pass its pointer to the MDD. You must set the function pointer to have a signature compatible with PFN_BATTERY_PDD_IOCONTROL.
The following code example shows how you should register the custom IOCTL handler in the PDD's BatteryPddInitialize function. The BatteryPDDIoControl function name in the code example below is a placeholder and is invoked through a function pointer.
DWORD BatteryPddIOControl(
DWORD dwContext,
DWORD dwIoctl,
PUCHAR pInBuf,
DWORD InBufLen,
PUCHAR pOutBuf,
DWORD OutBufLen,
PDWORD pdwBytesTransferred)
{
DWORD dwStatus = ERROR_SUCCESS;
// additional code
return dwStatus;
}
BOOL BatteryPddInitialize(LPCTSTR pszRegistryContext)
{
// additional code
gpfnBatteryPddIOControl = BatteryPddIOControl;
// additional code
}
See Also
Stream Interface Driver Development Concepts
Send Feedback on this topic to the authors