vb 获取指定进程个数

vb 获取指定进程个数,第1张

您好,我看到您的问题很久没有人来回答,但是问题过期无人回答会被扣分的并且你的悬赏分也会被没收!所以我给你提几条建议 一,你可以选择在正确的分类下去提问,这样知道你问题答案的人才会多一些,回答的人也会多些。 二,您可以到与您问题相关专业网站论坛里去看看,那里聚集了许多专业人才,一定可以为你解决问题的。 三,你可以向你的网上好友问友打听,他们会更加真诚热心为你寻找答案的,甚至可以到相关网站直接搜索 四,网上很多专业论坛以及知识平台,上面也有很多资料,我遇到专业性的问题总是上论坛求解决办法的。 五,将你的问题问的细一些,清楚一些!让人更加容易看懂明白是什么意思 谢谢采纳我的建议

Option Explicit Private Declare Function CreateToolHelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long Private Declare Function ProcessFirst Lib "kernel32" Alias "Process32First" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Function ProcessNext Lib "kernel32" Alias "Process32Next" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Const MAX_PATH As Integer = 260 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 MAX_PATH End Type Const TH32CS_SNAPheaplist = &H1 Const TH32CS_SNAPPROCESS = &H2 Const TH32CS_SNAPthread = &H4 Const TH32CS_SNAPmodule = &H8 Const TH32CS_SNAPall = TH32CS_SNAPPROCESS + TH32CS_SNAPheaplist + TH32CS_SNAPthread + TH32CS_SNAPmodule Private Sub Command1_Click() Dim i As Long, lPid As Long Dim Proc As PROCESSENTRY32 Dim hSnapShot As Long ListView1ListItemsClear '清空ListView hSnapShot = CreateToolHelpSnapshot(TH32CS_SNAPall, 0&) '获得进程“快照”的句柄 ProcdwSize = Len(Proc) lPid = ProcessFirst(hSnapShot, Proc) '获取第一个进程的PROCESSENTRY32结构信息数据 i = 0 Do While lPid <> 0 '当返回值非零时继续获取下一个进程 ListView1ListItemsAdd , "a " & i, Hex(Procth32ProcessID) '将进程ID添加到ListView1第一列 ListView1ListItems("a " & i)SubItems(1) = ProcszExeFile '将进程名添加到ListView1第二列 i = i + 1 lPid = ProcessNext(hSnapShot, Proc) '循环获取下一个进程的PROCESSENTRY32结构信息数据 Loop CloseHandle hSnapShot '关闭进程“快照”句柄 End Sub Private Sub Command2_Click() Dim lPHand As Long, TMBack As Long If ListView1SelectedItemText <> " " Then If MsgBox("确实要结束进程[ " & ListView1SelectedItemSubItems(1) & "]吗? ", vbYesNo) = vbYes Then lPHand = Val("&H " & ListView1SelectedItemText) lPHand = OpenProcess(1&, True, lPHand) '获取进程句柄 TMBack = TerminateProcess(lPHand, 0&) '关闭进程 If TMBack <> 0 Then MsgBox ListView1SelectedItemSubItems(1) & "已经被终止! " Else MsgBox ListView1SelectedItemSubItems(1) & "不能被终止! " End If CloseHandle lPHand Command1_Click '刷新进程列表 End If End If End Sub Private Sub form_Load() MeCaption = "进程管理器 " Command1Caption = "刷新 " Command2Caption = "结束进程 " ListView1ColumnHeadersClear ListView1ColumnHeadersAdd , "a ", "进程ID ", 600 ListView1ColumnHeadersAdd , "b ", "进程名 ", 4000 ListView1View = lvwReport Command1_Click '刷新进程列表 End Sub

以上就是关于vb 获取指定进程个数全部的内容,包括:vb 获取指定进程个数、VB“读取进程"这个应该如何表达、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/10092417.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-05
下一篇 2023-05-05

发表评论

登录后才能评论

评论列表(0条)

保存