1

Possible Duplicate:
Enumerating threads in Windows

I am trying to enumerate all threads belonging to a Win32 Window process.

I know I can get the process ID like so:

PDWORD procId;
GetWindowThreadProcessId(hwnd, procId);

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)
    {
        ...
    }
}

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.)

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.

Community
  • 1
  • 1
Ken Bellows
  • 6,711
  • 13
  • 50
  • 78

1 Answers1

3

See Thread Walking and Enumerating threads in Windows

Community
  • 1
  • 1
Roman R.
  • 68,205
  • 6
  • 94
  • 158