detect shutdown of other application

ganders

Active member
Joined
Nov 25, 2004
Messages
32
hi

i have a little application that is used to start a specific application (for example Word). my application is now supposed to run all the time the other application is running. as soon as the other application is closed by the user, my little application should also shutdown...

so, is there a way, that my application listens when the other application is closed?

tx for any help

georg
 
I am not very experienced, but what I can think of is a timer that checks every x seconds for the existence of a process:

Private OtherProcFound as Boolean = False

Private Sub QuitMe(ByVal myObject As Object, ByVal myEventArgs As EventArgs) Handles Timer1.Tick
Loop through the Processes
For Each Process In Process.GetProcessesByName("WinWord.exe")
OtherProcFound = True
Exit For
Next

If OtherProcFound = true Then
Me.Timer1.Stop
Then think of something to exit your program....
End If
End Sub
 
Im not very good with MS Word, but you should be able to declare a Word.Application variable using WithEvents. The event youd then be interested in is the Application_Quit() Event.
 
Last edited by a moderator:
Back
Top