My app needs to check and see if it is already running when launching so it doesn't open a second time. I have a system tray icon that can make the application visible = False. Works great. However, I need to make sure the user looks at the system tray for the notifyicon if the app is already running.
Private Sub mainWindowSmall_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim p() As Process
p = Process.GetProcessesByName("TSC Tool Box")
If p.Count > 0 Then
MessageBox.Show("The TSC Tool Box is already running. Check System tray!", _
"Warning !!!", MessageBoxButtons.OK, _
MessageBoxIcon.Error, MessageBoxDefaultButton.Button2)
Me.Close()
Else
totalOnLoad()
End If
End Sub
VB.NET | winforms
This feature is already built in to Windows Forms. Go to the project properties and click the "Single Instance Application" checkbox. There's also a StartupNextInstance event that you can handle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With