Intercept WM_CLOSE for cleanup operations

前端 未结 4 1014
悲哀的现实
悲哀的现实 2021-01-22 06:58

I have an external application that calls my application and is supposed to end it when the job is done. The log from this external application claims it uses WM_CLOSE

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-22 07:36

    The official solution for console applications is HandlerRoutine, a callback set by SetConsoleCtrlHandler. Windows will call your handler with a CTRL_CLOSE_EVENT argument in case of a WM_CLOSE exit.

    When you're using a class method with SetConsoleCtrlHandler, it must be a static method - Windows won't provide you with a this pointer.

提交回复
热议问题