c++ - 是否有任何 C 函数或 API 来获取在当前登录用户下运行的进程列表

标签 c++ c windows

我正在编写代码来搜索给定的 .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/

相关文章:

c - FreeMagic 和 GraphicsMagic 的链接问题

windows - ros::init(...) 抛出错误 - Windows roscpp

windows - 如何在 Windows 上更新 Composer ?

c++ - Gtk对话效果

c++ qt未定义对`_imp的引用

c++ - C++ 程序上的文件依赖性和模板问题

c++ - 如何从字符中读取 ASCII 值并将其转换为十六进制格式的字符串

c - x86 程序集 : What's the main prologue and epilogue?

c - 奇怪的双指针更新内存位置

windows - 创建一个 Windows 进程以静默检查丢失的 DLL