Application running

  • Thread starter Thread starter CJ Taylor
  • Start date Start date
C

CJ Taylor

Hey I think this has been answered before, but what is the way to see if a
previous version of the application is running?

Thanks,
CJ
 
Hi CJ,

|| Hey I think this has been answered before, but
|| what is the way to see if a previous version of the
|| application is running?

Sure has. Time and again. :-)

The following works for me. It relies on the caption of the main form.
Herfried has suggested using a Mutex which will work in the case that a
different app has the same title, or for apps that have a changeable title, or
none. I haven't tried it yet (it's on the todo).

Regards,
Fergus

'===================================================================
Public Shared Function tThereIsAnInstanceOfThisProgramAlreadyRunning _
(Optional tToActivateThePrevInstance As Boolean = False, _
Optional ProgramTitle As String = "?") As Boolean
Dim sProcessName As String
Dim aoProcList() As System.Diagnostics.Process

sProcessName = GetCurrentProcess.ProcessName
aoProcList = GetProcessesByName (sProcessName) 'At least 1.

If aoProcList.Length = 1 Then
'There's just me.
Return False
End If

If tToActivateThePrevInstance Then
ActivateMyBetterHalf (ProgramTitle)
End If

'Another me beat me to it.
Return True
End Function
 
Back
Top