Open or not

comcrack

Regular
Joined
Jun 14, 2003
Messages
52
Location
Canada
Hy


How can I do to when a program is running, if I open it again, it won't open but it will activate the program already opened. Like winamp.



Thank you

ComCrack
 
When the programe is running the first time, it will go to the there

Visual Basic:
Public Class Initialise
    
    Shared Sub Main()

        ' Prevent Multiple Instances of the Application
        Dim appProcesses As Process()

        appProcesses = Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName)

        If appProcesses.Length > 1 Then
            Application.Exit()
        Else
'''''''''''''''''''''It will go here''''''''''''''''''''
            Dim formMain = New frmMain()

            Application.Run(formMain)
        End If
    End Sub
End Class


But the second time it will go there

Visual Basic:
Public Class Initialise
    
    Shared Sub Main()

        ' Prevent Multiple Instances of the Application
        Dim appProcesses As Process()

        appProcesses = Process.GetProcessesByName(Diagnostics.Process.GetCurrentProcess.ProcessName)

        If appProcesses.Length > 1 Then
'''''''''''''''''''''It will go here''''''''''''''''''''
            Application.Exit()
        Else

            Dim formMain = New frmMain()

            Application.Run(formMain)
        End If
    End Sub
End Class


I want to activate(focus) the first program witch is running when the second close(Application.Exit()).


Like winamp: When click on the shortcut of winamp and it aready open, It will focus on the program already open.
 
Back
Top