well i have been playing with that mutex thingy
and this seems to be the solution, for your Terminal server problem
call it on start of your application with usercontex = true to support
multiple instances that run on a different user contex
call it on start of your application with usercontex = false to support only
one instance
Imports System.Threading
Private oMutex As Mutex
Private Function InstanceRunning(ByVal UserContex As Boolean) As Boolean
Dim progid As String = "{4C91B499-109B-42c8-B68E-E125F321EED6}" ' change the
id for every app you deploy ( tools ,create guid )
oMutex = New Mutex(False, String.Concat(progid, CStr(IIf(UserContex,
System.Environment.UserName, ""))))
If oMutex.WaitOne(0, False) = False Then
oMutex.Close()
Return True
End
End If
End Function
am i the only one who found this a verry interesting topic / task
regards
Michel Posseth [MCP]
"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:et**************@tk2msftngp13.phx.gbl...
Hi,
Use a mutex instead
http://www.vb-tips.com/default.aspx?...6-343ac05a7617
Ken
-------------------
"Xenio" <so***********@xenio-dev.com> wrote in message
news:eY**************@TK2MSFTNGP12.phx.gbl... Hi,
I'd like to make sure that only one instance of my app is running per
User Session. In addition this has to work with user rights and in a
Windows 2k/2k3 and Citrix Terminalserver environment.
The code I'm using prevents the app from creating a second instance on a
TS.
What do I have to change?
Dim handler As ThreadExceptionHandler = New ThreadExceptionHandler
AddHandler Application.ThreadException, AddressOf
handler.Application_ThreadException
Dim findProcesses(), thisProcess As Process
thisProcess = Process.GetCurrentProcess()
findProcesses = Process.GetProcessesByName(thisProcess.ProcessName )
If findProcesses.Length = 1 Then
Dim aForm As New myForm
Application.Run(aForm)
End If
Thanks in advance for any hint
Xenio