简体   繁体   English

使用带有任务列表的命令提示符进行 C++ 扫描进程 ID

[英]C++ scanning process ids using the command prompt with tasklist

I'm trying to use c++ to scan in the processes shown in the command prompt of windows when you type in tasklist.当您键入任务列表时,我正在尝试使用 C++ 扫描 Windows 命令提示符中显示的进程。 I haven't have the whole code ready but would like help in trying to read in the processes.我还没有准备好完整的代码,但在尝试阅读过程中需要帮助。

Well you can redirect the standard output, orrrr you can use winapi =)那么你可以重定向标准输出,或者你可以使用 winapi =)

List of functions to do with processes: http://msdn2.microsoft.com/en-us/library/ms684847.aspx与进程相关的函数列表: http : //msdn2.microsoft.com/en-us/library/ms684847.aspx

EnumProcesses function: http://msdn.microsoft.com/en-us/library/ms682629.aspx EnumProcesses 函数: http : //msdn.microsoft.com/en-us/library/ms682629.aspx

You'll need to use PSAPI to do this.您需要使用 PSAPI 来执行此操作。 You may need to add psapi.lib to your library dependencies.您可能需要将 psapi.lib 添加到您的库依赖项中。

You can use EnumProcesses to fill an array with the IDs of all running processes.您可以使用EnumProcesses用所有正在运行的进程的 ID 填充数组。 You can then use OpenProcess with the IDs in your array to retrieve a handle to each running process, then pass the handle to the relevant functions, such as QueryWorkingSet to get information about each process.然后,您可以使用OpenProcess和数组中的 ID 来检索每个正在运行的进程的句柄,然后将句柄传递给相关函数,例如QueryWorkingSet以获取有关每个进程的信息。

You can most likely find examples on the MSDN, if you need more help.如果您需要更多帮助,您很可能可以在 MSDN 上找到示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM