以下两种方法来自qq群,未经测试:


方法一:

If (UBound(Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName)) > 0) Then
MessageBox.Show("当前程序已启动,请使用Alt+Tab键进行切换!", "禁止运行 ", MessageBoxButtons.OK, MessageBoxIcon.Error)
Me.Close()
End
Exit Sub
End If


方法二:

        Dim bExist As Boolean = False
        Dim MyMutex As New System.Threading.Mutex(True, "随便给个名字", bExist) '互斥进程
  
        If bExist = False Then
            MessageBox.Show("程序已经运行!", "禁止多开", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Me.Dispose()
            End
        End If 

相关文章:

  • 2021-09-07
  • 2021-11-12
  • 2022-02-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
  • 2022-12-23
  • 2022-12-23
  • 2022-01-09
  • 2022-01-09
相关资源
相似解决方案