高手帮看看!谢谢!新建 1个 listbox 控件,命名 list1
代码如下Option Explicit
Private Const max_path = 260
Private Type processentry32
dwsize As Long
cntusage As Long
th32DefaultheapID As Long
th32moduleID As Long
cntthreads As Long
th32parentprocessID As Long
pcpriclassbase As Long
dwflage As Long
szexefile As String * max_path
End Type
Private Declare Function closehandle Lib " kernel32 " (ByVal hobject As Long) As Long
Private Declare Function createtoolhelp32snapshot Lib "kernel" (ByVal dwflage As Long, ByVal th32processid As Long) As Long
Private Declare Function process32first Lib "kernel" (ByVal hsnapshot As Long, lppe As Any) As Long
Private Declare Function process32next Lib "kernel32" (ByVal hsnapshot As Long, lppe As Any) As Long
Private Const th32cs_snapheaplist = &H1
Private Const th32cs_snapprocess = &H2
Private Const th32cs_snapthread = &H4
Private Const th32cs_snapmodule = &H8
Private Const th32cs_snapall = (th32cs_snapheaplist + th32cs_snapprocess + th32cs_snapthread + th32cs_snapmodule)
Private Const th32cs_inherit = &H80000000Private Sub from_load()
Dim hsnapshot As Long, lRet As Long, P As processentry32
P.dwsize = Len(P)
hsnapshot = createtoolhelp32snapshot(th32cs_snapall, ByVal 0)
If hsnapshot Then
lRet = process32first(hsnapshot, P)
Do While lRet
List1.AddItem Left$(P.szexefile, InStr(P.szexefile, Chr$(0)) - 1)
lRet = process32next(hsnapshot, P)
Loop
lRet = closehandle(hsnapshot)
End IfEnd Sub
代码如下Option Explicit
Private Const max_path = 260
Private Type processentry32
dwsize As Long
cntusage As Long
th32DefaultheapID As Long
th32moduleID As Long
cntthreads As Long
th32parentprocessID As Long
pcpriclassbase As Long
dwflage As Long
szexefile As String * max_path
End Type
Private Declare Function closehandle Lib " kernel32 " (ByVal hobject As Long) As Long
Private Declare Function createtoolhelp32snapshot Lib "kernel" (ByVal dwflage As Long, ByVal th32processid As Long) As Long
Private Declare Function process32first Lib "kernel" (ByVal hsnapshot As Long, lppe As Any) As Long
Private Declare Function process32next Lib "kernel32" (ByVal hsnapshot As Long, lppe As Any) As Long
Private Const th32cs_snapheaplist = &H1
Private Const th32cs_snapprocess = &H2
Private Const th32cs_snapthread = &H4
Private Const th32cs_snapmodule = &H8
Private Const th32cs_snapall = (th32cs_snapheaplist + th32cs_snapprocess + th32cs_snapthread + th32cs_snapmodule)
Private Const th32cs_inherit = &H80000000Private Sub from_load()
Dim hsnapshot As Long, lRet As Long, P As processentry32
P.dwsize = Len(P)
hsnapshot = createtoolhelp32snapshot(th32cs_snapall, ByVal 0)
If hsnapshot Then
lRet = process32first(hsnapshot, P)
Do While lRet
List1.AddItem Left$(P.szexefile, InStr(P.szexefile, Chr$(0)) - 1)
lRet = process32next(hsnapshot, P)
Loop
lRet = closehandle(hsnapshot)
End IfEnd Sub
解决方案 »
- 求助:数据库中数据的删除!!!
- 问个VB有关概念及控件向vb.net升级的有关疑问
- 刚写好的 老虎机(pc版),没找到上传的网址,要的帮顶!
- 如何绘制窗体菜单栏的背景(象超级解霸一样用图片作成的背景底纹)
- 请问有谁做过在网页上使用图表控件作图来进行数据库数据分析的?比如WEBCHART,UP也有分!在线急求
- VB读取EXCEL内容并存入数据库过程中如何去掉特殊字符
- ListView的ReportIcon图像显示位置
- vb读取jsp或html文件里出现乱码
- 关于控件.
- 头疼的问题,高手请入!谁能帮忙解决,奉送100分!!!分5次给分。
- 请教pHandle = OpenProcess(PROCESS_VM_READ, True, pid)的问题
- 请问我要把 CommandButton.visible的值取反,应该怎么写啊?
Dim theloop As Long, snap As Long
Dim Proc As PROCESSENTRY32
snap = CreateToolhelp32Snapshot(TH32CS_SNAPall, 0) '获得进程"快照"的句柄
Proc.dwSize = Len(Proc)
theloop = Process32First(snap, Proc) '获取第一个进程,并得到其返回值
While theloop <> 0 '当返回值非零时继续获取下一个进程
List1.AddItem Proc.szExeFile
theloop = Process32Next(snap, Proc)
Wend
CloseHandle snap '关闭进程"快照"句柄