title: Hook system power button in Windows
body: <p>I have a headless computer running a custom service that I want to enable/disable using the power button, rather than having to remotely connect every time. The computer does other things as well, so turning it off is not an option.</p>
  
  <p>Is it possible to hook the system power button under Windows XP &amp; up, such that my program would get the event <strong>before</strong> Windows initiates a powerdown/sleep event (before <code>PBT_APMQUERYSUSPEND</code> event get sent out)?</p>