How does task manager kill my program?

后端 未结 4 643
北恋
北恋 2021-01-18 00:22

I have this MFC program that when I kill it with task manager I get an exception on my program and then it crashes.

I want to get the event from the task manager, wh

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-18 00:58

    When you get a WM_CLOSE, you can easily detect that so your application can act upon it.

    I don't believe it's possible to know when TerminateProcess is being called to kill your application. The TerminateProcess documentation says it's an immediate and unconditional shutdown of the target process.

    (Depending on how much you want to achieve this, take a look at this link about hooking into the Windows API but don't expect it to be easy.)

提交回复
热议问题