问个在任务管理器中杀死窗口的问题

zjbirdman 2007-04-13 10:02:59
我在任务管理器中杀死一个进程,带窗口的,我把窗口给隐藏了
但是杀死时,怎么捕捉不到WM_CLOSE,WM_DESTROY这些消息啊
哪位高手可以指教一下啊
...全文
188 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
qqwwing 2007-04-13
  • 打赏
  • 举报
回复
强行关闭窗口是不会向其发送WM_CLOSE和WM_DESTROY这些"正常"的消息的,只有点退出或者右上角的关闭才会发送这些消息,这属于正常关闭。而用任务管理器关闭则是直接关闭,不管你程序的运行状态如何。你可以用SPY++看一下到底强行关闭会出现什么样的消息。我想是不是可以能通过异常处理监控程序的非正常关闭
zjbirdman 2007-04-13
  • 打赏
  • 举报
回复
up
WingForce 2007-04-13
  • 打赏
  • 举报
回复

强行关闭窗口是不会向其发送WM_CLOSE和 WM_DESTROY这些"正常"的消息的,只有点退出或者右上角的关闭才会发送这些消息,这属于正常关闭。而用任务管理器关闭则是直接关闭,不管你程序的运行状态如何。你可以用SPY++看一下到底强行关闭会出现什么样的消息。我想是不是可以能通过异常处理监控程序的非正常关闭
====================================================================================
用任务管理器杀进程相当于调用TerminateProcess
流程msdn上面这么说:

Terminating a process causes the following:


All object handles opened by the process are closed.
All threads in the process terminate their execution. Each thread exits when all its pending I/O has been completed or canceled. The process exits after all its threads exit.
The state of the process object becomes signaled, satisfying any threads that had been waiting for the process to terminate. The process object is deleted when the last handle to the process is closed.
The states of all threads of the process become signaled, satisfying any threads that had been waiting for the threads to terminate.
The termination status of the process changes from STILL_ACTIVE to the exit value of the process.

Terminating a process does not cause child processes to be terminated.

Neither the process nor any DLLs attached to the process are notified that the process is terminating. A process cannot prevent itself from being terminated.

Terminating a process does not generate notifications for WH_CBT hook procedures.


16,473

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Web++
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧