|
-
Mar 11th, 2002, 07:55 AM
#1
Thread Starter
Member
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.
-
Mar 11th, 2002, 10:17 AM
#2
Frenzied Member
The best (cleanest) way to close another app is to call Sendmessage API and send it's main window a WM_CLOSE message...
-
Mar 11th, 2002, 05:38 PM
#3
Hyperactive Member
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
-
Mar 12th, 2002, 07:24 AM
#4
Thread Starter
Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|