Need to know when a program has been closed

Hi,

I have a program in Visual Basic (P1) that needs to detect when a certain program P2 (developed in VC++) gets closed.

This programs P2 can be opened in any time during the execution of P1. P2 is launched from a third program P3 (VC++).

Since the program I need to detect its closing (P2) is set as TOPMOST,

I've tried to catch the form_focused event from P1 so it would detect

when the P2 is closed and the P1 gets the focus. But it didn't work. It

only entered the form_focused at the begining of the P1. What I'm doing

wrong?

Is there other way to know when P2 is closed?

Is there any way that P3 can notify P1 that P2 has been closed?

Thanks in advance.

[683 byte] By [rsacristanp] at [2007-12-22]
# 1

Try out your hands on

System.Diagnostics.Process.GetProcessById

and

System.Diagnostics.Process.GetProcessesByName

you need to keep a eye onto the process. which can be inside a timer or if you have the code for the P2 then you can write code to broadcast a notification using SendMessage/PostMessage that i going to close.

VikasVerma at 2007-8-30 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2

I was trying to avoid the use of a timer, but I guess is the way.

Thank you Vikas.

rsacristanp at 2007-8-30 > top of Msdn Tech,Visual Basic,Visual Basic General...