Edit

Responding to Battery Information Queries

The battery class driver calls the BatteryMiniQueryInformation routine to get a variety of information about the current battery. This routine is declared as follows:

typedef 
NTSTATUS
(*BCLASS_QUERY_INFORMATION)(
    IN PVOID Context,
    IN ULONG BatteryTag,
    IN BATTERY_QUERY_INFORMATION_LEVEL Level,
    IN LONG AtRate OPTIONAL,
    OUT PVOID Buffer,
    IN ULONG BufferLength,
    OUT PULONG ReturnedLength
    );

The Context parameter is a pointer to the context area that is allocated by the miniclass driver and passed to the class driver in the BATTERY_MINIPORT_INFO structure at device initialization. The BatteryTag parameter is a value previously returned by BatteryMiniQueryTag.

The Level parameter specifies the kind of information requested. The miniclass driver formats the information as a BATTERY_INFORMATION structure and returns it at the address supplied by Buffer, with a pointer to its length in ReturnedLength.

A miniclass driver should be prepared to handle requests for the following:

  • Battery capabilities, chemistry, capacity, low-capacity alert levels, and reserve charge

  • Temperature, in tenths of a degree Kelvin

  • Estimated remaining run time, in seconds

  • Device name

  • Manufacturer's battery model name

  • Date of manufacture

  • Unique ID

  • Serial number

Some batteries are not capable of reporting all this information. A miniclass driver should return STATUS_INVALID_DEVICE_REQUEST for any information that its device cannot supply.