VB6's 'PrevInstance' function, so they suggest making your own with the
following code:
Function PrevInstance() As Boolean
If
(UBound(Diagnostics.Process.GetProcessesByName(Dia gnostics.Process.GetCurrentProcess.ProcessName))
0) Then
Return True
Else
Return False
End If
End Function
The only problem is that the VB.NET documentation qualifies this with the
comment that "once a second instance is loaded, the first instance will also
return true". For example, as soon as a second app is opened while the first
is already open, I can force the new app instance to close. But ever after
that I get a value of TRUE back, even if one of our users is trying to open
the application after having gone through a situation where they opened it
twice. I end up having to get the user to log out and back in again to reset
the process count.
Is there a better way to detect and kill duplicate app instances? Where is
the process count stored ... in the registry? (Can I reset it from in the
program when I close a duplicate instance)?
Thanks for help in advance,
Tom