Program already running

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How would one check to see if a program is already running? I don't want my
app to be launched more than once.

Thanks,
Mark
 
#Region "Previous Existance (FUNCTION)"

Private Function PrevInstance() As Boolean
If
UBound(System.Diagnostics.Process.GetProcessesByName(System.Diagnostics.Proc
ess.GetCurrentProcess.ProcessName)) > 0 Then
Return True
Else
Return False
End If
End Function

#End Region

Usage:
--------

If PrevInstance() = True Then
MessageBox.Show("Application is already running")
End ' Must call end & not 'Application.Exit()' here
End If
 
Crouchie1998 said:
Private Function PrevInstance() As Boolean
If
UBound(System.Diagnostics.Process.GetProcessesByName(System.Diagnostics.Proc
ess.GetCurrentProcess.ProcessName)) > 0 Then

Note that process names are not necessarily unique.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top