While I don't have the code, can't you just check WMI for HasBattery property (I think that is the property name)?