メモ帳でファイルを開き、終了された場合にメッセージを表示してみます。
Private WithEvents Pnotepad As New System.Diagnostics.Process
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
Try
Pnotepad = System.Diagnostics.Process.Start("notepad.exe", "C:\work\aiueo.xml")
Pnotepad.EnableRaisingEvents = True
Pnotepad.SynchronizingObject = Me
Catch ex As Exception
Pnotepad.Close()
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
End Try
End Sub
Private Sub Pnotepad_Exited(ByVal sender As Object, ByVal e As System.EventArgs) _
Handles Pnotepad.Exited
MessageBox.Show("メモ帳(aiueo.xml)が終了しました。")
Pnotepad.Close()
End Sub