views:

59

answers:

1

I am developing a windows service, in vb .et, that launches a legacy application that performs some work. The service acts as a wrapper around the legacy app allowing users to automate an otherwise manual operation.

Everything is working great, except occasionally the legacy app displays a messagebox. When it does this the process halts until the message box is closed.

As the service will be running on a server there will be no user to close the message box.

The service launches the legacy application in a System.Diagnostics.Process.

My question is, is there way to detect that a message box has been displayed by a process that I have started using System.Diagnostics.Process and is there a way to through code to close the messagebox.

I've tried to be brief so if you need more information please let me know.

Thanks in advance

Richie

+1  A: 

Use FindWindow to find the app, the use EnumChildWindows to enumerate all it's childwindows until you find the messagebox (if the messagebox isn't a direct child of the main window of the app you might have to have recursive calls I think).

You might be able to skip the FindWindow call and instead use the MainWindowHandle property of the Process, but I haven't checked if that works.

A good tool for looking at all this is Spy++ which can help you see some information you can get hold of about a running process.

ho1
richie