Win32:我如何枚举属于C ++中的一个进程的所有线程? [英] Win32: How do I enumerate all the threads belonging to a process in C++?

查看:671
本文介绍了Win32:我如何枚举属于C ++中的一个进程的所有线程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

枚举Windows中的主题

我想枚举所有属于

我知道我可以这样获得进程ID:

I know I can get the process ID like so:

PDWORD procId;
GetWindowThreadProcessId(hwnd, procId);

我知道整个事情可以在C#中完成,如下:

And I know that the whole thing can be done in C# like so:

// get process that owns the taskbar window
int procId;
GetWindowThreadProcessId(hwnd, out procId);

Process p = Process.GetProcessById(procId);
if (p != null)
{
    foreach (ProcessThread t in p.Threads)
    {
        ...
    }
}

但是据我所知,Process类是一个.NET类我错了),我试图我最难避免.NET依赖。 (阅读:请不要告诉我只使用.NET。)

But as far as I can tell the Process class is a .NET class (please correct me if I'm wrong), and I'm trying my hardest to avoid .NET dependency. (Read: Please don't tell me to just use .NET.)

所以问题是这样:有一个Win32等同, PID?

So the question is this: Is there a Win32 equivalent, given that I have correctly retrieved the PID?

(另外,我看到了工具帮助库在另一个问题中引用,但不确定是否是最好的选项。如果是,可以给出 >

(As a side note, I saw the Tool Help Library referenced in another question, but was not sure it was the best option. If it is, could you give a brief explanation/demonstration of how I would accomplish this or direct me to someone else's?)

一如往常,非常感谢所有的帮助。

As always, thanks immensely for all the help.

推荐答案

请参阅 Thread Walking 枚举Windows中的主题

这篇关于Win32:我如何枚举属于C ++中的一个进程的所有线程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆