Results 1 to 2 of 2

Thread: Check for other opened application and trigger the exit button

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2009

    Check for other opened application and trigger the exit button


    I have this code which works OK. However, I want to update it abit to check if another application is opened. If it is opened then trigger the exit button to close the application...

    Private Sub App_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
    		Dim intResponse As MsgBoxResult
    		intResponse = MessageBox.Show("Are you sure you want to exit the application?", "CPRD Apps", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
    		If intResponse = MsgBoxResult.No Then
    			e.Cancel = True
    			Exit Sub
    		End If
    	End Sub
    The above is the main application (CPRD Apps) - in its main form (FrmMain.vb) I call another application by the code shown below..

    	Private Sub BtnGCPMDev_Click(sender As Object, e As EventArgs) Handles BtnGCPMDev.Click
    		Dim sArguments As String
    		sArguments = "\\PDFs01\CPRDAppsAccessPoint\GCPMDev\bin\GCPMDev.exe"
    	End Sub
    Now on GCPMDev (FrmMain.vb) I have a Toolbar with a ToolBarButton9 which calls the exit function as;

    If e.Button Is ToolBarButton9 Then
                Call exitGCPM()
            End If
    Now, the idea is if GCPMDev is opened while you try to close CPRD Apps, it triggers the Toolbarbutton9 in GCPMDEV (FrmMain.vb). Therefore, you will never have GCPMDev opened while CPRD Apps is CLOSED. Note, the are two different applicationas with different logins credentials, database are different etc.

    How can I easily achieve this?

    Thank you
    Last edited by dr223; Dec 11th, 2014 at 05:44 AM.

  2. #2
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Chelmsford UK

    Re: Check for other opened application and trigger the exit button

    you could use this:

    Dim p As Process = Process.GetProcessesByName("GCPMDEV").FirstOrDefault
    If p IsNot Nothing Then
        '"GCPMDEV" is running
        'shut down process
    End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width