当前位置:酷百书>百科问答>如何用VB编写一个用于结束进程的程序

如何用VB编写一个用于结束进程的程序

2023-03-19 19:18:46 编辑:join 浏览量:629

如何用VB编写一个用于结束进程的程序

如何用VB编写一个用于结束进程的程序

第一种方法:

hWndClock = FindWindow(vbNullString, "要关闭的窗口的标题")

Dim Ret As Long

Ret = SendMessage(hWndClock, WM_CLOSE, 0&, 0&)

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Public Const WM_CLOSE = &H10

第二种方法:

Public Function KillPID(ByVal PID As Long) As Boolean

Dim lProcess As Long, Ret As Long

lProcess = OpenProcess(&H1F0FFF, False, PID)

Ret = TerminateProcess(lProcess, 0&)

If Ret <> 0 Then

KillPID = True

End If

CloseHandle lProcess

End Function

有关API自己用API浏览器得到即可

如:

temp1 = Shell(“notepad.exe")

~~~~~~~~

Call KillPID(temp1) '即可关闭

标签:VB,编写,进程

版权声明:文章由 酷百书 整理收集,来源于互联网或者用户投稿,如有侵权,请联系我们,我们会立即处理。如转载请保留本文链接:https://www.kubaishu.com/answer/175644.html
热门文章