使用CMD根据进程名结束进程

0 Reply , Posted in 程序代码 on 2016 08, 2016

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

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

用VB制作外挂   (2017-3-1 16:16:53)

发表评论:



◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

                       

  鄂公网安备 42112502000156号     鄂ICP备16019550号