Sir,
I want to know how a running application/program could be stopped/closed through vb code.
Printable View
Sir,
I want to know how a running application/program could be stopped/closed through vb code.
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 cmdCloseApp_Click()
Dim lngCloseIt As Long
lngCloseIt = FindWindow(vbNullString, "Caption Of Window To Be Closed")
PostMessage lngCloseIt, WM_CLOSE, CLng(0), CLng(0)
End Sub
'Occassionally WM_QUIT is necessary to use