How can i kill a background process !
hi,
can anyone tell me how i can kill a background process in VB running in wondows :sick: ? process like apache server, sql server or any other unwanted process that i dont need at the moment ? :)
if possible please tell me which functions to use or which reference to be added ? :cool: code snipets are welcome as well. :thumb:
Re: How can i kill a background process !
try this code
VB Code:
'Module Declaration
Option Explicit
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Const WM_CLOSE = &H10
'Code
Public Sub CloseProgram(ByVal Caption as String)
Dim Handle As Long
Handle= FindWindow(vbNullString, Caption)
If Handle = 0 Then Exit Sub
SendMessage Handle, WM_CLOSE, 0&, 0&
End Sub
'BUTTON
Private Sub Command1_Click()
CloseProgram ("Title/Name of the Application")
End Sub
Re: How can i kill a background process !
Re: How can i kill a background process !
That will work for processes with a visible window and/or window caption. To truely close a program you need to Terminate its process. Search the forums for Terminate Process and you will find many examples already, a couple by me too. :)