2020年6月11日 星期四

vb.net 禁止重復執行 [Do not repeat start Process]


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim bExist As Boolean = False
        Dim MyMutex As New System.Threading.Mutex(True, "SmallGCOk", bExist) '互斥進程

        If bExist = False Then
            MessageBox.Show("程序已經運行!", "禁止多開", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Me.Dispose()
            End
        End If
    End Sub

沒有留言:

張貼留言