How to Prevent Visual Basic Exe being executed multiple times
At times we set/reset registry settings / environment variables as part of the program logic. If another instance of the application uses this concurrently it would become a mess. The best is to prevent the application from being loaded for the second time. The easy way to do is to use App.PrevInstance method as shown below.
If App.PrevInstance = True Then
MsgBox "An instance of this tool is running in this machine! Requested instance will terminated", vbExclamation
Exit Sub
End If
No comments:
Post a Comment