You first create a snapshot of a process through the CreateToolhelp32Snapshot function, and then iterate through the process by calling Process32First using the handle returned by the snapshot, where the relevant information is stored in an instance of the PROCESSENTRY32 struct type. And then show it.
Winxp+vb6+sp6
The code is as follows:
Private Declare Function createtoolhelp32snapshot Lib "kernel32" (ByVal dwflags as Long, ByVal Th32processid as Long) as L Ong
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
' Add ListView control, 3 buttons
' Delete the selected process in ListView
Private Sub Command2_Click ()
If MsgBox ("Do you want to delete" & ListView1.SelectedItem.SubItems (2) & "process?", vbYesNo + vbquestion) <> vbyes Then
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.