Private Sub Form_Load() '读取系统中所有进程。
ListKillProcess1.List_Processes = True
ProcessList.Clear
For i = 1 To ListKillProcess1.Number_Of_Processes
ListKillProcess1.Get_Process_Info = i
ProcessList.AddItem Str(i) + " " + ListKillProcess1.Process_Name
Next i
MaxNumberOfProcesses = ListKillProcess1.Number_Of_Processes
End Sub
Private Sub NewProGramFile_click()'获得进程句柄。
ListKillProcess1.Get_Process_Info = MaxNumberOfProcesses
ListKillForm.Caption = ListKillProcess1.Process_Name
If Left(ListKillProcess1.Process_Name, 12) = "要查找的进程句柄的进程名称" Then
msgbox ListKillProcess1.Process_ID 'MSGBOX找到句柄ListKillProcess1.Process_ID
ListKillProcess1.List_Processes = True
end If
End Sub
Private Sub Timer1_Timer() '时间控件检查是否系统新运行了进程
ListKillProcess1.List_Processes = True
ListKillProcess1.Get_Process_Info = ListKillProcess1.Number_Of_Processes
If ListKillProcess1.Number_Of_Processes > MaxNumberOfProcesses Then
NewProGramFiles = ListKillProcess1.Process_Name
MaxNumberOfProcesses = MaxNumberOfProcesses + 1
Call NewProGramFile_click '系统如果运行了新的进程测检查是为要查看的进程并由 此 过程(newProgramfile_click)获得句柄并显示。
Else
MaxNumberOfProcesses = ListKillProcess1.Number_Of_Processes
End If
End Sub
ListKillProcess控件可以在这里下载:www.vbaspnew.com/ziyuan/k/kz/6.zip
1、此代码的前提是先运行此段代码
2、必须知道你要查看句柄的进程名。(但可以通过修改返回所有新增进程的ID和名称)