Hi,
the OpenNETCF (www.opennetcf.org) has a function for getting battery status, amongst many other functions

It is open source

HTH

Pete