Hi,
Q: Do you want App1 to close down or just the forms (child forms)?
A: Better to close App1 if a connection was already established early at startup. I pasted sample codes that can help you. If you want, however, to close only the child forms (MDI), then ... we may have to look for the proper API for this.
From AllAPI network,
How can I close an application?
You can always use the FindWindow-function and the PostMessage-function to find the wanted application, and then send it a message that it has to close itself. One disadvantage: you'll need the exact caption of this application.
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, lParam As Any) As Long
Const WM_CLOSE = &H10
Private Sub Form_Load()
Dim winHwnd As Long
Dim RetVal As Long
winHwnd = FindWindow(vbNullString, "Calculator"

If winHwnd <> 0 Then
PostMessage winHwnd, WM_CLOSE, 0&, 0&
Else
MsgBox "The Calculator is not open."
End If
End Sub
Use the
FindWindow to get the window handle of App1 by passing App1's title (what appears in the task bar) to
FindWindow. Once you have the handle, use it to
PostMessage passing WM_CLOSE constant (it's like Windows will "click" the close button of App1 for you). Where to place the codes and what follows I leave to you.
![[peace] [peace] [peace]](/data/assets/smilies/peace.gif)