The attached Visual Studio 2008 project builds an API to access the battery health indicator:

It finds standard battery life (GetBatteryLife API), which is a wrapper for Micrsoft's GetSystemPowerStatusEx2 function, and it also exposes the function GetBatteryHealth, which gets the rating you see above in the picture.