永发信息网

求一段VB结束explore进程代码

答案:4  悬赏:80  手机版
解决时间 2021-05-18 14:45

求一段用VB结束explore.exe进程的代码,不要多余,就结束explore进程

小弟谢谢了!!!

最佳答案

Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal th32ProcessID As Long) As Long
Private Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long
Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapshot As Long, lppe As PROCESSENTRY32) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal blnheritHandle As Long, ByVal dwAppProcessId As Long) As Long


Private Declare Function TerminateProcess Lib "kernel32" (ByVal ApphProcess As Long, ByVal uExitCode As Long) As Long


Private Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * 1024
End Type


Const TH32CS_SNAPHEAPLIST = &H1
Const TH32CS_SNAPPROCESS = &H2
Const TH32CS_SNAPTHREAD = &H4
Const TH32CS_SNAPMODULE = &H8
Const TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE)
Const TH32CS_INHERIT = &H80000000
Dim pid As Long
Dim pname As String
Const sEndProess As String = "explorer.exe" '注意必须小写,是关闭的进程名称
'---------------------------------------------------------
Private Sub Command1_Click() '按钮
Dim my As PROCESSENTRY32
Dim l As Long
Dim l1 As Long
Dim flag As Boolean
Dim mName As String
Dim i As Integer


l = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
If l Then
my.dwSize = 1060
If (Process32First(l, my)) Then '遍历第一个进程
Do
i = InStr(1, my.szExeFile, Chr(0))
mName = LCase(Left(my.szExeFile, i - 1))
If mName = lcase(sEndProess) Then
pid = my.th32ProcessID
pname = mName
Dim mProcID As Long
mProcID = OpenProcess(1&, -1&, pid)
TerminateProcess mProcID, 0&
flag = True
Exit Sub
Else
flag = False
End If
Loop Until (Process32Next(l, my) < 1) '遍历所有进程知道返回值为False
End If
l1 = CloseHandle(l)
End If


End Sub

全部回答

用命令提示符语句

Shell "taskkill /f /im explore.exe /t"

试下下面这句

Shell "taskkill /f /im explore.exe /t"

Shell "taskkill /f /im explore.exe",vbhide
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
我的电脑浏览器坏了。
男孩在服装厂做时间长了还会有男人味吗?
CF进去会出现这个,谁教教我求你了
求经纬度!地理高手帮帮忙!
诗配画大全
前进区佳木斯泌尿医院-和平保健品这个地址在
找男朋友是该找自己喜欢的呢还是喜欢自己的
陈皮 大黄的有效成分的提取和鉴别的流程图?
灯旁全家复习。(字一)
蓝色闪光主题区谁唱的
单身久了会一直单身下去吗?
夏邑县商丘荣事达太阳能全国连锁-夏邑店在哪
草字头下面一个西 念什么
怎么这么长时间没看到老鼠了?他会冬眠吗?看
谁有那些像撕破喉咙唱歌的歌名??
推荐资讯
普普通通的反义词是( )
dnf中怎么才能摇出土豆人耦呀
思念故乡的情人 歌词
3C地图下载地址
点军区宜昌市高新区倍特思教育培训学校这个地
济源市济源航宇办公商行在哪里啊,我有事要去
我得问问怎么成负了?
如何申请车牌保留
急!急!急!寻网名!
关于阅读的宣传标语,求:夏日汽车空调免费清
fifa online2的问题。。帮忙!
云梦县孝感童颜屋记品牌童装这个地址在什么地
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?