Open or not

comcrack

Well-known member
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 wont 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

Code:
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

Code:
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