'Dim WMI As Object, pp, p As Object
'Dim i As Integer
'得到管理对象
Set WMI = GetObject("winmgmts://./root/cimv2")
'查询进程
Set p = WMI.ExecQuery("select * from Win32_Process ")
'保存结果
s = ""
l = ""
icount = 0
For Each pro In p
icount = icount + 1
'为兼容各系统,处理
l = Trim(pro.Caption) & ", " & Trim(pro.ProcessId) & "," & Trim(Left(pro.CreationDate, 14)) & "," & vbCrLf
On Error Resume Next
l = Trim(pro.Caption) & ", " & Trim(pro.ProcessId) & "," & Trim(Left(pro.CreationDate, 14)) & "," & Trim(pro.CommandLine) & vbCrLf
s = s & l
'结束?不要用
'Pro.Terminate()
'Debug.Print pro.Caption, pro.ProcessId, Left(pro.CreationDate, 14), pro.CommandLine
Next
i = 1
j=1
Do While i < Len(s)
if MsgBox ( "进程总数 " & icount & " (格式 ID PID Time)" & vbCrLf & Mid(s, i, 999),68,"是否继续下一页?当前页" & j & "/" & int(len(s)/1000) + 1)<>6 then
exit do
end if
j=j+1
i = i + 999
Loop