|
-
Nov 14th, 2001, 02:03 AM
#1
Thread Starter
New Member
unloading an non-VB related app
I'm opening an .exe through a invisible MDI form.
How can I unload this .exe afterwards
-
Nov 14th, 2001, 04:33 AM
#2
Conquistador
what is the executables window caption?
-
Nov 14th, 2001, 12:56 PM
#3
da_silvy asked about the caption of the open window because that is what is used to close another running application (regardless of how it got running). If you know the caption, then use this.
VB 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 Const WM_QUIT = &H12
Private Sub Command1_Click()
Dim CloseIt As Long
CloseIt = FindWindow(vbNullString, "Caption Of Window To Be Closed")
PostMessage CloseIt, WM_CLOSE, CLng(0), CLng(0)
End Sub
-
Nov 15th, 2001, 02:01 AM
#4
Conquistador
VB 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 Const WM_QUIT = &H12
Private Sub Command1_Click()
Dim CloseIt As Long
CloseIt = FindWindow(vbNullString, "Caption Of Window To Be Closed")
If CloseIt <> 0 Then PostMessage(CloseIt, WM_CLOSE, CLng(0), CLng(0))
End Sub
It's a better idea to only post the message if a window is found
I think it might hang otherwise 
If it's an office program, you can close it with other methods also
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
|