What happens when you close a c++ console application

前端 未结 4 612
南笙
南笙 2020-11-28 12:00

I guess the question says it all, but, what happens if someone closes a c++ console app? As in, clicks the \"x\" in the top corner. Does it instantly close? Does it throw so

4条回答
  •  一生所求
    2020-11-28 12:45

    Closing a c++ console app with the "x" in the top corner throws an CTRL_CLOSE_EVENT which you could catch and process if you set a control handler using the SetConsoleCtrlHandler function. In there you could override the close functionality and perform whatever you wished to do, and then optionally still perform the default behavior.

提交回复
热议问题