title: Win32: How do I enumerate all the threads belonging to a process in C++?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1206878/enumerating-threads-in-windows">Enumerating threads in Windows</a>  </p>
  </blockquote>
  
  
  
  <p>I am trying to enumerate all threads belonging to a Win32 Window process.</p>
  
  <p>I know I can get the process ID like so:</p>
  
  <pre><code>PDWORD procId;
  GetWindowThreadProcessId(hwnd, procId);
  </code></pre>
  
  <p>And I know that the whole thing can be done in C# like so:</p>
  
  <pre><code>// 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)
      {
          ...
      }
  }
  </code></pre>
  
  <p>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.)</p>
  
  <p>So the question is this: Is there a Win32 equivalent, given that I have correctly retrieved the PID?</p>
  
  <p>(As a side note, I saw the <a href="http://msdn.microsoft.com/en-us/library/ms686837%28VS.85%29.aspx" rel="nofollow noreferrer">Tool Help Library</a> referenced in another question, but was not sure it was the best option. If it is, could you give a <em>brief</em> explanation/demonstration of how I would accomplish this or direct me to someone else's?)</p>
  
  <p>As always, thanks immensely for all the help.</p>