Código (vb) [Seleccionar]
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hWnd As Long, lpdwProcessId As Long) As Long
Private Declare Function OpenProcess Lib "Kernel32" (ByVal dwDesiredAccessas As Long, ByVal bInheritHandle As Long, ByVal dwProcId As Long) As Long
Private Declare Function TerminateProcess Lib "Kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Function KillProcessByWindowName(Window As String)
Dim lnghProcess As Long
Dim lngReturn As Long
Dim lpProc As Long
Dim gtWnd As Long
gtWnd = FindWindow(vbNullString, Window)
Call GetWindowThreadProcessId(gtWnd, lpProc)
WindowToProcessId = lpProc
lnghProcess = OpenProcess(1&, -1&, WindowToProcessId)
lngReturn = TerminateProcess(lnghProcess, 0&)
End Function
Private Sub Command1_Click()
Call KillProcessByWindowName(App.Title)
End Sub