Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Closing an app from another app

Status
Not open for further replies.

Gazzza

Programmer
Dec 21, 2000
16
0
0
AU
Hi

What I need to do is close a named application through code from another application. There are three apps 1,2 and 3
1 is running 2 is checking that it running and 3 may or may not be running. If 2 detects that 1 is no longer running it needs to shut down 3. I'm using FindWindow to check if 3 is running or not and now I just need to close it. Can anyone help me out. I'm a newbie, so if I need to use an API call could you also tell me a bit about the parameters it will need to be passed.

Garry
 
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Const WM_CLOSE = &H10

Private Sub CloseWindow(hWnd as long)
Call SendMessage(hWnd, WM_CLOSE, 0&, ByVal 0&)
End Sub

=======

Hi,

All you have to do is call the CloseWindow function and specify the hWnd from the window you want to close. The hWnd of the window you are looking for is the returned value of the FindWindow function.

Thats all :)

LuCky
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top