프로세스 중복실행 방지 팁
*
프로세스 중복실행 방지 팁

Public Class Form1

    Private P As Process
    Private app As String = "notepad"

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        P = Process.Start(app)
    End Sub


    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        For Each proc As Process In Process.GetProcessesByName(app)
            If proc.Id <> P.Id Then
                proc.CloseMainWindow()
            End If
        Next
    End Sub
End Class

이 게시물을

댓글'1'

Public Class Form1
    Private PG_ProcessID As Process
    Private PG_app As String = "notepad"


    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load

        Process.Start("notepad")
    End Sub


 
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Dim currentProcessId As Integer = System.Diagnostics.Process.GetCurrentProcess.Id

        Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName(PG_app)

        For Each p As Process In pProcess

            If p.Id <> currentProcessId Then

                p.Kill()

            End If

        Next
    End Sub

  
End Class
 

이 댓글을

공유하기

SEARCH

MENU NAVIGATION