If all your batteries run out then the machine will be returned to the state that it was in when you bought it. Next time you switch it on, the operating system will be copied from hidden flash memory to RAM.
You will loose any programs that you, yourself installed, and any data that was stored in RAM (for instance your contacts database).
Unless you kept a backup, then there is no way to restore this data. You can backup the units contacts database very quickly using Settings-->System-->Permanent Save. If you set this up then it will save your data away in flash memory. It will only save the data types listed (in the dialogue), it will not save away any software that you installed or any data that you created with that software.
To ensure that you dont loose any data, I recommend periodically backing the unit up, either to your PC using activesync, or to either the internal flash or an SD flash card. I have software on mine called xBackup, your's may have the same software. You can use xbackup to perform full system backups.
If you have a backup from xbackup (or similar) then you can use this to restore your systems state after a hard reset (or power failure).