title: Return FALSE to WM_QUERYENDSESSION can not prevent Windows7 from shutdown
body: <p>I am following these sample codes on MSDN to prevent windows 7 from shutdown until user confirm:</p>
  
  <pre><code>    private static int WM_QUERYENDSESSION = 0x11;
      private static bool systemShutdown = false;
      protected override void WndProc(ref System.Windows.Forms.Message m)
      {
          if (m.Msg == WM_QUERYENDSESSION)
          {
              MessageBox.Show("queryendsession: this is a logoff, shutdown, or reboot");
              systemShutdown = true;
          }
  
          // If this is WM_QUERYENDSESSION, the closing event should be
          // raised in the base WndProc.
          base.WndProc(ref m);
  
      } //WndProc 
  
      private void Form1_FormClosing(System.Object sender, System.ComponentModel.CancelEventArgs e)
      {
          if (systemShutdown)
          // Reset the variable because the user might cancel the 
          // shutdown.
          {
              systemShutdown = false;
              if (DialogResult.Yes == MessageBox.Show("My application",
                  "Do you want to save your work before logging off?",
                  MessageBoxButtons.YesNo))
              {
                  e.Cancel = true;
              }
              else
              {
                  e.Cancel = false;
              }
          }
      }
  </code></pre>
  
  <p>But the problem I am facing is on one PC, even if "queryendsession: this is a logoff, shutdown, or reboot" is shown ( so WM_QUERYENDSESSION is received ), Windows 7 does not wait for user's confirm and shutdowns quickly. On other PCs these codes work well. So I am wondering what is happening. Thank you very much.</p>
  
  <p>Btw: I tried to directly send out e.Cancel = false in Form1_FormClosing but nothing happend. System shutdowns and there was no waiting.</p>