title: CtrlHandler not called on event CTRL_CLOSE_EVENT in Windows Web Server 2008
body: <p>I have a console application which uses <code>SetConsoleCtrlHandler</code> to set a handler which handles and <code>CTRL_CLOSE_EVENT</code>. The handler simply returns <code>TRUE</code> which will cause a dialog box to appear and prompt the user to continue shutdown or cancel.</p>
  
  <p>The software runs on Windows XP SP3 and Windows Web Server 2008 SP2.</p>
  
  <p>On XP, when the 'X' on the console window is clicked, my control handler gets called and a prompt appears as expected. On Server 2008 closing the console window does not call my control handler and the application closes down without prompting.</p>
  
  <p>To check that the control handler is being set correctly I have added a case for <code>CTRL_C_EVENT</code>. I can see the code get called for Ctrl-C.</p>
  
  <p>Are there any differences in the way close events are handled in Server 2008? It seems like they do not go through the ctrl handlers at all.</p>
  
  <p><strong>EDIT:</strong> Looking at the MSDN page for <code>SetConsoleCtrlHandler</code> I can't find any information about <code>CTRL_CLOSE_EVENT</code> no longer being handled in Vista and later.</p>
  
  <p>If you are dealing with windows (<code>HWND</code>) instead of console ctrl events, is it possible to get the close messages sent to the console window and handle that?</p>