Function 进程路径(Optional exen) 'Debug.Print 进程路径("EXCEL.EXE") If IsMissing(exen) Then exen = "EXCEL.EXE" Set p = GetObject("WinMgmts:").InstancesOf("Win32_Process") For Each Pj In p If Pj.Description = exen Then 进程路径 = Pj.ExecutablePath Next End Function
Function 进程命令(Optional exen) 'Debug.Print 进程路径("EXCEL.EXE") If IsMissing(exen) Then exen = "EXCEL.EXE" Set p = GetObject("WinMgmts:").InstancesOf("Win32_Process") For Each Pj In p If Pj.Description = exen Then 进程命令 = Pj.Commandline Next End Function
Function 进程路径列表(Optional exen) 'Debug.Print 进程路径列表("EXCEL.EXE") If IsMissing(exen) Then exen = "EXCEL.EXE" Set p = GetObject("WinMgmts:").InstancesOf("Win32_Process") For Each Pj In p If Pj.Description = exen Then 进程路径列表 = 进程路径列表 + Chr(13) + Pj.ExecutablePath Next End Function
Function 进程命令列表(Optional exen) 'Debug.Print 进程命令列表("EXCEL.EXE") If IsMissing(exen) Then exen = "EXCEL.EXE" Set p = GetObject("WinMgmts:").InstancesOf("Win32_Process") For Each Pj In p If Pj.Description = exen Then 进程命令列表 = 进程命令列表 & Chr(13) & Pj.Commandline Next End Function
Function 进程列表(Optional d) 'Debug.Print 进程列表() 'd=1仅进程,2进程+路径,3进程+路径参数 If IsMissing(d) Then d = 3 Set p = GetObject("WinMgmts:").InstancesOf("Win32_Process") For Each Pj In p i = i + 1 If d = 1 Then tmp = tmp & i & vbTab + Pj.Description + Chr(13) If d = 2 Then tmp = tmp & i & vbTab + Pj.Description + Chr(13) + vbTab + Pj.ExecutablePath + Chr(13) If d = 3 Then tmp = tmp & i & vbTab + Pj.Description + Chr(13) + vbTab + Pj.Commandline + Chr(13) Next 进程列表 = tmp End Function