사전 셋팅
표준 WinForms 프로젝트로 시작하십시오. 모듈을 추가하십시오. Public Sub Main을 추가하십시오. 프로젝트 -> 속성 -> 응용 프로그램 탭으로 이동 하여 "응용 프로그램 프레임 워크 사용"상자를 선택 해제 하십시오. 위의 "시작 개체 :"드롭 다운에서 "Form1"을 "Sub Main"으로 변경하십시오.
========================================
Module Module1
Public Sub Main()
Application.Run(New Watchdog)
End Sub
End Module
Public Class Watchdog
Inherits ApplicationContext
Private AppToWatch As String
'Private FullPath As String = "C:\WINDOWS\system32\calc.exe"
Private FullPath As String = My.Computer.FileSystem.SpecialDirectories.ProgramFiles & "\TOP_GUARD\svctop_dwm"
Private WithEvents P As Process
Public Sub New()
AppToWatch = System.IO.Path.GetFileNameWithoutExtension(FullPath)
Dim PS() As Process = Process.GetProcessesByName(AppToWatch)
If PS.Length = 0 Then
StartIt()
Else
P = PS(0)
P.EnableRaisingEvents = True
End If
End Sub
Private Sub P_Exited(sender As Object, e As EventArgs) Handles P.Exited
StartIt()
End Sub
Private Sub StartIt()
P = Process.Start(FullPath)
P.EnableRaisingEvents = True
End Sub
End Class