C++ Get Username From Process

前端 未结 4 2059
小蘑菇
小蘑菇 2020-11-29 11:39

I have a process handle with

HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, 0, THE_PROCESS_ID);

How can I get t

4条回答
  •  再見小時候
    2020-11-29 12:13

    Use OpenProcessToken to get the token (obviously), then GetTokenInformation with the TokenOwner flag to get the SID of the owner. Then you can use LookupAccountSid to get the username.

提交回复
热议问题