Reading the battery voltage with a microcontroller ?

If I have a micro controller attached directly to a battery pack (say 3XAA) and would like to get a warning before running out of power, could I then just pull a pin high followed by a analogRead of that pin?

Will that give the same result as connecting the pin to "+" on the battery and reading it, or is there some voltage drops I should know of?

This is a good approach, no additional pins required.
http://code.google.com/p/tinkerit/wiki/SecretVoltmeter

Nice!

But how about ATtinies and the like?

You will have to check each datasheet. You are looking for an ADMUX /MUX setting for reading the band-gap voltage (labeled Vbg in the ATtiny85 datasheet) and an ADMUX / REFS setting for External Voltage Reference.

You can also check the Analog to Digital Converter Block Schematic (ironically, the ATtin85 datasheet has a mistake on the Block Schematic indicating that it is not possible to read the band-gap using an external reference).