How do you get the UserName of the owner of a process?

后端 未结 7 1663
迷失自我
迷失自我 2020-12-06 16:28

I\'m trying to get a list of processes currently owned by the current user (Environment.UserName). Unfortunately, the Process class doesn\'t have a

7条回答
  •  再見小時候
    2020-12-06 17:25

    The CodeProject article How To Get Process Owner ID and Current User SID by Warlib describes how to do this using both WMI and using the Win32 API via PInvoke.

    The WMI code is much simpler but is slower to execute. Your question doesn't indicate which would be more appropriate for your scenario.

提交回复
热议问题