Public Class MyProcess
    Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
    Declare Function PostMessage Lib "user32.dll" Alias "PostMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Integer)
    Private Const WM_QUIT = &H12
    Private Const WM_CLOSE = &H10


    Public Function RunProcess(ByVal 파일이름 As String, Optional ByVal 실행옵션 As String = vbNullString) As Boolean
        Dim RunP As Process
        Dim B As System.Diagnostics.ProcessStartInfo = New System.Diagnostics.ProcessStartInfo

        If FileIO.FileSystem.FileExists(파일이름) Then
            B.FileName = 파일이름
            B.WorkingDirectory = 파일이름.Substring(0, 파일이름.LastIndexOf("\"))
            B.Arguments = 실행옵션
            RunP = Process.Start(B)
            Return True
        Else
            Return False
        End If
    End Function

    Public Function checkmyproc(ByVal 프로세스명 As String) As Boolean
        Dim Prc() As Process = Process.GetProcesses  '//현재프로세스배열을 가져온다.
        Dim MyPrc As Process
        Dim 파일명 As String = 프로세스명.Substring(프로세스명.LastIndexOf("\") + 1).ToUpper
        For Each MyPrc In Prc
            If (MyPrc.ProcessName & ".EXE").ToUpper = 파일명 Then Return True
        Next
        Return False
    End Function



    Public Sub KillMyProc(ByVal 클래스명 As String)
        Dim Np As IntPtr
        Np = FindWindow(클래스명, vbNullString)
        'Me.lstOutput.Items.Add("WHND:" & Np.ToInt32.ToString)
        If Np = 0 Then
            'Form_Standard.MDIMessage.Text = "Cannot Find :" & 클래스명
            Exit Sub
        End If
        PostMessage(Np.ToInt32, WM_QUIT, 0&, 0&)
        Sleep(500)
    End Sub
    Public Sub oKillMyProc(ByVal 프로세스명 As String)
        Dim Prc() As Process = Process.GetProcesses  '//현재프로세스배열을 가져온다.
        Dim MyPrc As Process
        Dim 파일명 As String = 프로세스명.Substring(프로세스명.LastIndexOf("\") + 1).ToUpper
        For Each MyPrc In Prc
            If (MyPrc.ProcessName & ".EXE").ToUpper = 파일명 Then

                '    MsgBox(MyPrc.StartInfo.Fileame)
                MyPrc.Kill()
            End If
        Next
        Sleep(500)
    End Sub
End Class
