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
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