It was asked two or three times already on this Forum but I simply hate to use EnumWindows and compare the PID's (GetWindowThreadProcessID). Anyone has an idea of another way to get the handle of a window from a process ID ? The processes were started by ShellExecuteEx.

Thanks in advance,
bazik
Posted on 2002-09-12 07:46:14 by bazik
Use GetThreadDesktop from user32.dll.
here's the description,
http://leb.net/wine/WinDoc/msdn/sdk/platforms/doc/sdk/win32/func/src/f41_8.htm

edit:
Oh sorry that's wrong...
Posted on 2002-09-12 08:15:50 by C.Z.
Thanks for your reply, but it doesnt work.
Note that I have a process ID, not a thread ID :/
Posted on 2002-09-12 08:32:20 by bazik
EnumThreadWindows

I do think you have to get the thread ID beforehand, as windows are only entitled to the thread that created them, not the process.

How do you get the process ID in your app, I wonder? If you use toolhelp functions, you can get the thread ID at the same time.

I don't yet know how to get the main thread ID from a known process ID. But it's for sure that, if you use CreateProcess instead of ShellExecuteEx, threadid will be no problem.
Posted on 2002-09-12 09:03:21 by C.Z.