任务管理器如何杀死我的程序? [英] How does task manager kill my program?

查看:348
本文介绍了任务管理器如何杀死我的程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个MFC程序,当我杀死它与任务管理器我得到一个异常,我的程序,然后它崩溃。

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, when it is going to kill my process and close my program gracefully.

我知道有很多方法,任务管理器正在使用,以杀死一个过程。

I understand that there are few methods that the task manager is using in order to kill a process.

1)从应用程序选项卡,有人告诉我,它正在发送WM_CLOSE消息到我的应用程序的主可视窗口,如果我的应用程序没有下来,秒,任务管理器检测它为不响应,并对其进程使用TerminateProcess()。

1) From the applications tab, someone told me it is sending WM_CLOSE message to my application's main visible window, And if my application is not going down after few seconds, the task manager detects it as not-responding and uses TerminateProcess() on its process.

2)从进程选项卡,有人告诉我,它正在使用TerminateProcess )windows API。

2) From the process tab, someone told me it is using TerminateProcess() windows API.

任务管理器正在使用什么其他方法?

Is there any other method the Task Manager is using?

最后2种方法?

提前感谢。

推荐答案

,这两个都是正确的。您应该回复WM_CLOSE以正常关闭。这可能来自任何地方,而不只是任务管理器(例如关闭)。

Yes, both of these are correct. You should respond to WM_CLOSE to close gracefully. This could come from anywhere, not just task manager (shutdown for instance).

MFC通常处理WM_CLOSE。如果你的应用程序没有响应,那么你的主线程必须坐下做别的事情,或者更有可能是你的描述在WM_CLOSE处理程序的某处崩溃。

MFC normally handles WM_CLOSE. If your app is not responding then your main thread must be sat doing something else, or more likely from your description is crashing somewhere in the WM_CLOSE handler.

应用程序来查找异常被提出的位置?

Can you debug your app to find where the exception is being raised?

这篇关于任务管理器如何杀死我的程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆