Results 1 to 4 of 4

Thread: Shut Down Another Application

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2002
    Posts
    43

    Shut Down Another Application

    I am shelling out to another application from within my application. I wanted to know what is the best way for me to shutdown the app that I shelled out to??

    Also, if the user quits the other app, I want my app to shutdown as well.

  2. #2
    Frenzied Member MerrionComputin's Avatar
    Join Date
    Apr 2001
    Location
    Dublin, Ireland
    Posts
    1,616
    The best (cleanest) way to close another app is to call Sendmessage API and send it's main window a WM_CLOSE message...
    ----8<---------------------------------------
    NEW - The .NET printer queue monitor component
    ----8<---------------------------------------
    Now with Examples of use

  3. #3
    Hyperactive Member BrandonTurner's Avatar
    Join Date
    Sep 2001
    Location
    East Lansing, Michiagn
    Posts
    268
    Code:
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    
    Private Const WM_CLOSE = &H10
    
    Private Sub cmdCloseApp_Click()
    Dim CloseIt As Long
    CloseIt = FindWindow(vbNullString, "Caption Of Window To Be Closed")
    PostMessage CloseIt, WM_CLOSE, CLng(0), CLng(0)
    End Sub

  4. #4

    Thread Starter
    Member
    Join Date
    Feb 2002
    Posts
    43
    Thanks for your help people.

    I opened the app with the shell command. Should I have used an API call instead??

    Also, what will get returned if the FindWindow function doesn't find the caption...0????

    I am concerned if the user exits the other app prematurely, what are the problems of trying to send the close message if the app is already closed.

    Thanks again

    Mike

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