2016-11-8
18:40

root
root

[程序代码]使用CMD根据进程名结束进程

----------------根据进程名终止进程----------------
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

文章如需转载请注明:转载自: 紫灵幽梦
« 上一篇 下一篇 »

相关文章:

vb读取access并且显示  (2017-5-11 9:18:27)

VB 获取CPU温度示例  (2017-5-8 10:35:11)

VB程序逆向反汇编常见的函数   (2017-5-8 10:32:0)

VB内嵌汇编的模块示例  (2017-5-8 10:24:4)

win7系统里面的UAC关闭方法  (2017-5-4 8:29:57)

内存数据的读写(PC)   (2017-3-1 17:51:40)

发表留言: