title: How to detect whether Windows is shutting down or restarting
body: <p>I know that when Windows is shutting down, it sends a <a href="http://msdn.microsoft.com/en-us/library/aa376890(VS.85).aspx" rel="noreferrer">WM_QUERYENDSESSION</a> message to each application. This makes it easy to detect when Windows is shutting down. However, is it possible to know if the computer going to power-off or is it going to restart after Windows has shutdown.</p>
  
  <p>I am not particularly hopeful, considering the documentation at MSDN has this to say about <code>WM_QUERYENDSESSION</code>: "...it is not possible to determine which event is occurring," but the cumulative cleverness of stackoverflow never ceases to amaze me.</p>