防止同一个程序多次运行

Function IsSingleInstance() As Boolean

If UBound(Diagnostics.Process.GetProcessesByName( _
Diagnostics.Process.GetCurrentProcess.ProcessName)) > 0 Then
Return False
Else
Return True
End If

End Function

调用:
If IsSingleInstance() = False Then
msgbox "二重起動"
Application.Exit()
Exit Sub
End If

你可能感兴趣的:(程序)