Click here to Skip to main content
14,661,186 members
Rate this:
Please Sign up or sign in to vote.
See more:
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
Posted
Comments
#realJSOP 3-Dec-10 11:30am
   
Use the Add Comment link under the message you want to reply to.

Rate this:
Please Sign up or sign in to vote.

Solution 3

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".
   
v2
Comments
Vishal Kumar Soni 3-Dec-10 15:13pm
   
Thanks Pasztorpisti.
Rate this:
Please Sign up or sign in to vote.

Solution 1

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


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.
   
Comments
Vishal Kumar Soni 3-Dec-10 11:34am
   
Hi John,

Thanks for your reply.

You are right that it is poorly written code but I can not provide patch now as it on live system.All system get blocked due to this.

So that's why, for time I want to write process which can kill this dialog box and restart the parent process.

Please give some idea.

Thanks
Vishal

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100