HOWTO: Detect Closure of Command Window from a Console App

Q102429


The information in this article applies to:


SUMMARY

Win32 console applications run in a command window. So that the console application can detect when the console is closing, register a console control handler and look for the following values in your case statement:


   CTRL_CLOSE_EVENT     User closes the console
   CTRL_LOGOFF_EVENT    User logs off
   CTRL_SHUTDOWN_EVENT  User shuts down the system 
For an example, see the CONSOLE sample. For more information, see the entry for SetConsoleCtrlhandler() in the Win32 application programming interface (API) reference.

Additional query words:

Keywords : kbConsole kbKernBase kbOSWin2000 kbDSupport kbGrpDSKernBase
Issue type : kbhowto
Technology : kbAudDeveloper kbWin32sSearch kbWin32API


Last Reviewed: October 27, 2000
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.