如果我知道进程ID(PID),如何确定启动进程的用户名? [英] How can I determine the user name that started a process if I know the process id (PID)?
本文介绍了如果我知道进程ID(PID),如何确定启动进程的用户名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的专家
对不起,我好像停电了。我找不到一种方法来获取运行进程的用户名,并从中了解PID。我用谷歌搜索,但没有成功。
N.B:PID我在CreateToolhelp32Snapshot的帮助下获得。
我使用OpenProcess和GetStartupInfo的想法似乎是为了naiv。
标签似乎无效。我正在使用W32-API。
[/编辑]
你能给我一个暗示/想法吗?>
非常感谢您提前。
Dear experts
Sorry it seems I have a blackout. I cannot find a way to get the user name under which a process is running and from which I know the PID. I googled for it, but without success.
N.B: PID I get by the help of CreateToolhelp32Snapshot.
And my thinking using OpenProcess and GetStartupInfo seems to be to naiv.
The tags seem to be not valid. I'm working with W32-API.
[/Edit]
Can you give me please an hint/idea?
Thank you very much in advance.
推荐答案
使用此序列方法...
1.获取处理程序对于这个过程
OpenProcess功能(Windows) [ ^ ]
2.打开一个令牌 - 基于流程处理程序 - 获取对信息的访问权限
OpenProcessToken function(Windows) [ ^ ]
3.获取相关信息(使用TOKENUSER标志)
GetTokenInformation函数(Windows) [ ^ ]
4.获取用户信息
LookupAccountSid函数(Windows) [ ^ ]
Use this sequence of methods...
1. Get a handler for the process
OpenProcess function (Windows)[^]
2. Open a token - based on the process handler - to gain access to the info
OpenProcessToken function (Windows)[^]
3. Get the relevant info (use TOKENUSER flag)
GetTokenInformation function (Windows)[^]
4. Get user info
LookupAccountSid function (Windows)[^]
这篇关于如果我知道进程ID(PID),如何确定启动进程的用户名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文