why windll.user32.GetWindowThreadProcessID can't find the function?
<p>I'm reading <em>Black Hat Python</em> and in chapter 8 I find "user32.GetWindowThreadProcessID(hwnd,byref(pid))" doesn't work, just like the picture shows.</p>

<p>It seems that python can't find <em>GetWindowThreadProcessID</em>, but it can find <em>GetForegroundWindow</em> which also is exported from user32.dll.</p>

<p>I also try "windll.LoadLibrary("user32.dll")", but it still doesn't work.</p>

<p>Thank you!</p>

<p>It should work if you your OS version is at least Windows 2000 Professional:</p>

<pre><code>import ctypes
import ctypes.wintypes
pid = ctypes.wintypes.DWORD()
hwnd = ctypes.windll.user32.GetForegroundWindow()
print( ctypes.windll.user32.GetWindowThreadProcessId(hwnd,ctypes.byref(pid)) )
</code></pre>

python