
Originally Posted by
zarix
that is what i have to search from google right ? :P
Just add a small function like this
Code:
Sub CloseIfFound(ByVal ProcessName As String)
Dim P = Process.GetProcessesByName(ProcessName)
If P.Length = 0 Then Return
Application.Exit()
End Sub
And on a timer
Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
CloseIfFound("notepad")
End Sub
Or add it directly into the timer
Code:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim P = Process.GetProcessesByName("notepad")
If P.Length = 0 Then Return
Application.Exit()
End Sub
Dim P = Process.GetProcessesByName("notepad")
Will look for notepad in the process list and store it in an array of processes.
If P.Length = 0 Then Return
If none matching notepad are found, the array will be empty, hence returning if the value is zero.
Application.Exit()
If one or more matching the process name you're after is found, the code will never return and Application.Exit() gets called closing your form.