This sample shows how to obtain information from the APM system (Advanced Power Management). It can retrieve info like is this computer hooked into the AC line or is it battery powered and if so, how long do the batteries last.

The program also contains a sample of how to interact with suspend notifications (although i must confess canceling a users choice didn't work well).