For the umpteenth time my laptop just shut down in the middle of my game because my power cable had disconnected without me noticing it.
Now I want to write a little
This may very much depend on your exact operating system. Here are some calls for windows XP, I am sure you can find the Vista equivalents:
http://msdn.microsoft.com/en-us/library/ms704147(VS.85).aspx