
kill a process from visual basic
Hello, you can kill a proccess easily from vb with the code below. Hopefully it
helps.
Public Declare Function GetWindowThreadProcessId Lib "user32" Alias
"GetWindowThreadProcessId" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Public Declare Function TerminateProcess Lib "kernel32" Alias
"TerminateProcess" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Public Declare Function OpenProcess Lib "kernel32" Alias "OpenProcess" (ByVal
dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As
Long) As Long
Public Sub KillProcess(hWnd As Long)
Dim pId As Long
Call GetWindowThreadProcessId(hWnd, pId)
Call TerminateProcess(OpenProcess(&H1F0FFF, 0&, pId), 0&)
End Sub
(you can get the window handle by using the findwindow api call)
Enjoy.
-c/c