----------------根据进程名终止进程----------------
Shell "taskkill /f /im qq.exe", 0 '用CMD结束QQ
----------------根据标题名终止进程----------------
Public Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Const PROCESS_TERMINATE = &H1
'以上代码须添加在模块里
Private Sub Command1_Click()
Dim hwnd&, pid&, ret&
hwnd = FindWindow(vbNullString, "QQ2011") '获取窗口句柄
GetWindowThreadProcessId hwnd, pid
ret = OpenProcess(PROCESS_TERMINATE, True, pid) '获取进程句柄
TerminateProcess ret, 0 '终止指定进程及其所有线程
End Sub