我正在编写代码来搜索给定的 .exe 文件是否在特定用户帐户下运行。 是否有任何 API 可以获取在特定用户下运行的进程列表。或者我们可以从 C++ 中的进程中获取进程的用户名。
我在互联网上进行了一些搜索,发现“CreateToolhelp32Snapshot”会有所帮助。但它返回系统中所有用户下运行的所有进程。我想要打印在特定用户下运行的进程。
最佳答案
I am writing a code to search whether the given .exe file is running under the specific user account or not.
使用OpenProcessToken
获取 token (显然),然后 GetTokenInformation
使用 TokenUser
标志获取所有者的 SID。然后你可以使用LsaLookupSids2
获取用户名。
Is there any API to get the list of process running under the specific user... But
CreateToolhelp32Snapshot
returning all the process that runs under all users in the system.
可以通过上面的方法从中过滤掉指定的用户。
关于c++ - 是否有任何 C 函数或 API 来获取在当前登录用户下运行的进程列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57652732/