欢迎来到电脑知识学习网,专业的电脑知识大全学习平台!

手机版

win10任务主机进程停止-(win10任务主机进程停止运行)

软件应用 发布时间:2022-12-24 10:51:13
win10任务主机进程停止 (win10任务主机进程停止运行)

'强制终止进程 2022.10.25

'说明:FindWindow取得窗口的句柄,用GetWindowThreadProcessid取得进程的procid,以procid为参数用OpenProcess取得进程句柄,用TerminateProcess终止该进程,hprocess为进程句柄,uExitCode为0

Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long '检索处理顶级窗口的类名和窗口名称匹配指定的字符串。这个函数不搜索子窗口。

Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal Hwnd As Long, lpdwProcessId As Long) 电脑 As Long '取得进程的 Procid

Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long

Public Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long

Public Function ZzJc(CkBt As String, GbLx As Integer) As Long '终止进程,窗口标题,关闭类型,返回值(0关闭失败,1关闭成功,指定窗口不存在)

Dim Hwnd As Long '窗口句柄

Dim Procid As Long '进程ID

Dim ProId As Long

Dim hPro As Long '进程句柄

' CkBt = "模拟器" & Format(Val(Form2.Text10.Text), "#00")

Hwnd = FindWindow(vbNullString, CkBt) '用FindWindow函数查找指定的"模拟器"窗口

Delay 100

If Hwnd = 0 Then

Form2.Text11.Text = "不存在"

ZzJc = 2

Form2.Text14.Text = ZzJc

Exit Function

End If

Form2.Text11.Text = Hwnd


Procid = GetWindowThreadProcessId(Hwnd, ProId) '取该窗口所属电脑 的进程ID

Delay 100

Form2.Text12.Text = ProId


hProc = OpenProcess(&H1, True, ProId) '获取进程句柄

Delay 100

Form2.Text13.Text = hProc


ZzJc = TerminateProcess(hProc, 0) '关闭进程

Delay 100

Form2.Text14.Text = ZzJc


End Function


电脑
责任编辑:电脑知识学习网

软件应用