title: How to detect power button event and deny it on windows 7 from laptop
body: <p>On windows XP, I can detect event when pushing power button of laptop.
  Condition to get APMQUERYSUSPEND event is option of [control panel->power option->system setting->when I press the power button->sleep] must be changed to ‘Sleep’. </p>
  
  <pre><code>MainFrm::OnPowerBroadcast(WPARAM wParam, LPARAM lParam)
  </code></pre>
  
  <p>{</p>
  
  <pre><code>         switch (wParam)
  
           {
  
                         case PBT_APMQUERYSUSPEND:
  
                         // Ask question whether to power off or not
  
                         // If not, return BROADCAST_QUERY_DENY
  
                         return BROADCAST_QUERY_DENY;
  
           }
  </code></pre>
  
  <p>But from windows 7, I don't have any clue to detect the event. 
  Based on windows 7, APMQUERYSUSPEND event was removed. Even though I tried SetThreadExecutionState API to block turn-off, it dose not work. 
  <a href="http://msdn.microsoft.com/ko-kr/library/windows/desktop/aa372716(v=vs.85).aspx" rel="nofollow">http://msdn.microsoft.com/ko-kr/library/windows/desktop/aa372716(v=vs.85).aspx</a> </p>
  
  <p>Do you know any idea to catch event when pushing power button?</p>
  
  <p>Thanks.</p>