> Dim nProcessID As Integer = 0 > Dim tempprocess As Process > tempprocess = checkInstance() > If Not tempprocess Is Nothing Then > nProcessID = tempprocess.Id > AppActivate(nProcessID) > > 'MsgBox("Läuft schon") ' means "Already running" > End > End If > Else > Dim cText As String = My.Computer.Clipboard.GetText > oData = getclipclassic(cText) > ' MsgBox(oData.Count) > End If >................... > Public Function checkInstance() As Process > Dim cProcess As Process = process.GetCurrentProcess() > Dim aProcesses() As Process = process.GetProcessesByName(cProcess.ProcessName) > 'loop through all the processes that are currently running on the > 'system that have the same name > For Each process As Process In aProcesses > 'Ignore the currently running process > If process.Id <> cProcess.Id Then > 'Check if the process is running using the same EXE as this one > If Reflection.Assembly.GetExecutingAssembly().Location = cProcess.MainModule.FileName Then > 'if so return to the calling function with the instance of the process > Return process > End If > End If > Next > > > > 'if nothing was found then this is the only instance, so return null > Return Nothing > End Function > > Public Function getCombookProcessId() As Integer > Dim cComBook As String = "ComBook" > Dim cPName As String = "" > Dim nRet As Integer = 0 > Dim aP() As Process = Process.GetProcesses > For Each Process As Process In aP > cPName = Process.MainWindowTitle.ToUpper > If cPName.IndexOf("COMBOOK") > -1 Then > nRet = Process.Id > End If > Next > Return nRet > End Function >Thank you, Thomas