1,486
社区成员
发帖
与我相关
我的任务
分享
Option Explicit
Private Sub Form_Load()
getProcessCommandLine "rundll32.exe"
End Sub
'得到所有进程名为proName的详细列表,参数一定要写完整。
Private Function getProcessCommandLine(ByVal proName As String) As String
Dim objWMIService As Object
Dim colProcessList As Object
Dim objProcess As Object
Dim objProType As Object
Dim strResult As String
Set objWMIService = GetObject("winmgmts:" & "{impersonationlevel=impersonate}!//./root/cimv2")
Set colProcessList = objWMIService.ExecQuery("Select * from Win32_Process Where Name='" & proName & "'")
If colProcessList.Count <> 0 Then
For Each objProcess In colProcessList
For Each objProType In objProcess.Properties_
If objProType.Name = "CommandLine" Then
strResult = strResult & objProType.Value & vbCrLf
Exit For
End If
Next
Next
End If
If strResult <> "" Then
getProcessCommandLine = strResult
MsgBox strResult
End If
End Function