Is my program already running?

  • Thread starter Thread starter Scott Meddows
  • Start date Start date
S

Scott Meddows

How can I tell if my program is already running in memory? Code is
appreciated.

Thanks
 
Check you System.Diagnostics.Processes collection to see if a process with
the same name is running

-CJ
 
Scott Meddows said:
How can I tell if my program is already running in memory? Code is
appreciated.

'Check to see if a previous instance of this application is running already
If
(UBound(Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurren
tProcess.ProcessName)) > 0) Then
MessageBox.Show("Already running a copy of this program on your
system.", , MessageBoxButtons.OK, MessageBoxIcon.Information)
Return False
Exit Function
End If


--
------------------------------------------------------------------------
George Shubin Custom Software Development
dX Software Systems Database Applications
Ph: 503-981-6806 Fax: 503-982-0120
www.dxonline.com (e-mail address removed)
------------------------------------------------------------------------
 
Thanks. EXACTLY what I needed!

George Shubin said:
'Check to see if a previous instance of this application is running already
(UBound(Diagnostics.Process.GetProcessesByName(Diagnostics.Process.GetCurren
tProcess.ProcessName)) > 0) Then
MessageBox.Show("Already running a copy of this program on your
system.", , MessageBoxButtons.OK, MessageBoxIcon.Information)
Return False
Exit Function
End If


--
------------------------------------------------------------------------
George Shubin Custom Software Development
dX Software Systems Database Applications
Ph: 503-981-6806 Fax: 503-982-0120
www.dxonline.com (e-mail address removed)
 
* "Scott Meddows said:
Thanks. EXACTLY what I needed!

But won't work if there are 2 or more apps with the same name (but
different apps) running on the machine. I know, that's a rare case, but
it can happen for simple app names like "Calc" or something like that.

For alternatives, see other replies.
 
Herfried K. Wagner said:
But won't work if there are 2 or more apps with the same name (but
different apps) running on the machine. I know, that's a rare case,
but it can happen for simple app names like "Calc" or something like
that.

But you can start calc twice!
;->
 
* "Armin Zingler said:
But you can start calc twice!
;->

But my own "Calc" replacement only allows one instance and it should
still run if Windows' Calc is running.
 
*Slaps Herfried in Head*

Was it really "necessary" to write your own Calc app? Cmon now. =)
 
Back
Top