vb如何获取进程用户名

pid = 1872 '进程的pid

Set wmi = GetObject("winmgmts:\\.\root\cimv2")

Set ps = wmi.ExecQuery("select * from win32_process where ProcessId=" & pid)

For Each p In ps

p.GetOwner user, domain

MsgBox "PID 是 " & pid & " 的进程的用户名是 " & user

Next