Initialize the battery class device

In the AddDevice routine, you must initialize the battery class device and register the miniclass driver with the class driver. To do this, call the BatteryClassInitializeDevice routine. This action registers the miniclass driver with the class driver, allowing them to use each other's support routines. Additionally, it registers the battery device with the system, making it visible to the composite battery and the power meter.

To call BatteryClassInitializeDevice, provide a pointer to a BATTERY_MINIPORT_INFO structure containing the following information:

  • MajorVersion and MinorVersion: The major and minor version numbers of the class driver supported by this miniclass driver. These version numbers are defined in Batclass.h as BATTERY_CLASS_MAJOR_VERSION and BATTERY_CLASS_MINOR_VERSION, respectively.
  • QueryTag: The entry point of the miniclass driver's BatteryMiniQueryTag routine.
  • QueryInformation: The entry point of the miniclass driver's BatteryMiniQueryInformation routine.
  • SetInformation: The entry point of the miniclass driver's BatteryMiniSetInformation routine.
  • SetStatusNotify: The entry point of the miniclass driver's BatteryMiniSetStatusNotify routine.
  • DisableStatusNotify: The entry point of the miniclass driver's BatteryMiniDisableStatusNotify routine.
  • Context: A pointer to the miniclass driver's context information, typically a pointer to the FDO device extension. This pointer is passed back to the miniclass driver each time the class driver calls a BatteryMiniXxx routine.
  • Pdo: A pointer to the PDO for the device.
  • DeviceName: A NULL parameter, as PnP devices should not have names.

After setting up this structure, call BatteryClassInitializeDevice and pass a pointer to the BATTERY_MINIPORT_INFO structure. In return, you'll receive a handle for subsequent calls to battery class driver support routines. Store the returned class handle in nonpaged memory.

Following the BatteryClassInitializeDevice call, the AddDevice routine may also need to initialize other device-specific data.