杀死与对话框相关的进程 [英] Kill the process related to dialog box

查看:104
本文介绍了杀死与对话框相关的进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



假设任何应用程序都崩溃了,并且出现了一个对话框,它将阻止所有其他应用程序,直到有人确认为止.

因此,我想编写另一个进程,将继续检查是否存在任何对话框.因此,如果此对话框与应用程序X相关,则将其杀死.
谁能帮我找到以下内容:
1)如何找到对话框
2)对话框的父进程.

如果有人可以帮助我,那将是很大的帮助.

问候,
Vishal Soni

Hi,

Suppose there is crash in any application and some dialog box appears.It will block all other applications until someone acknowledge this.

So I want to write a another process which will keep on checking that whether there is any dialog box.So if this dialog box is related to application X then kill it.
Can any one help me to find following:
1) How can I find that there is dialog box
2) Parent process of dialog box.

If anyone can help me then it would be great help.

Regards,
Vishal Soni

推荐答案

您可以使用FindWindow(classname, windowtitle)搜索窗口.参数之一可以为NULL.如果这样做不起作用,则可以尝试使用EnumWindows()的蛮力方法.此后,我们有零个,一个或多个需要测试的HWND.您可以通过调用GetWindowThreadProcessId()来测试窗口,该返回返回创建窗口的进程的ID,以及返回创建指定窗口的进程内的线程的ID.如果需要进程的句柄,则可以通过调用OpenProcess()将进程ID转换为句柄,以后可以根据需要将其传递给TerminateProcess().

注意:使用winapi对话框功能创建的普通对话框通常是从wndclass#32770"实例化的.
You can search for a window with FindWindow(classname, windowtitle). One of the parameters can be NULL. If this doesn''t do the job than you can try a bruteforce approach with EnumWindows(). After this we have zero, one, or more HWNDs that need testing. You can test a window by calling GetWindowThreadProcessId() that returns the id of the process that created the window and also the id of the thread inside the process that created the specified window. If you need a handle to the process then you can convert the process id to a handle by calling OpenProcess(), and later you can pass this to TerminateProcess() if you like.

Note: Normal dialogs created with winapi dialog functions are usually instantiated from wndclass "#32770".


假设任何应用程序都崩溃了,并且出现了一些对话框.将阻止所有其他应用程序,直到有人确认.



好吧,如果它阻塞了所有其他应用程序,那么它要么是重要的操作系统消息,要么是编写不当的应用程序.来自一个应用程序的对话框不应阻止不相关的应用程序的处理.

您可以做自己想做的事,但是要实施它需要很多周到,努力和谨慎.这样的事情在最坏的情况下很容易在你身旁横冲直撞.



Well, if it''s blockiing all other applications, it''s either an important OS message, or a poorly-written appliccation. A dialog box from one application should not block unrelated applications from processing.

You can do what you want to do, but it would take a lot of forethought, effort, and caution to implement. It would be very easy for something like this to go sideways on you at the worst possible moment.


这篇关于杀死与对话框相关的进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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