GetWindowThreadProcessId can not find my window handle, even though its process ID exists on Window
<p>I have a setup application that if user clicks the same setup twice, they would get the pop up message "Another setup instance already running". Upon clicking OK on that message I want to put focus back on the existing installation window which has been running.  I currently have the following codes:</p>

<pre><code>if("setup.exe" == CString(buffer))
EnumWindows(EnumWindowsProc,(LPARAM)processID);


BOOL CALLBACK EnumWindowsProc(HWND windowHandle,LPARAM lParam)
{
DWORD searchedProcessId = (DWORD)lParam;
DWORD windowProcessId = 0;

GetWindowThreadProcessId(windowHandle,&amp;windowProcessId);

if(searchedProcessId == windowProcessId)
{
       //Set focus when detects the right window.
       SetForegroundWindow(windowHandle);
       return FALSE;
}
return TRUE;
 } 
</code></pre>

<p>The above code works if I stay on the first screen/step on the installation wizard (install shield).  </p>

<p>When I move to the next screen on the installation wizard, this focus logic no longer works.  Upon debugging I found that the function GetWindowThreadProcessId could not find any windowProcessID that match searchedProcessId.  I also confirmed the following:</p>

<ul>
<li>the searchProcessId value remains the same whether I am on the 1st or 2nd installation screen.</li>
<li>I confirmed I see the searchProcessID value exists when I view in in the window task manager.</li>
</ul>

<p>I read up on GetWindowThreadProcessId and see the following note: <strong><em>"The return value is the identifier of the thread that created the window."</em></strong>  In my own interpretation, was this because the 2nd step/screen on the wizard is generated by its own thread?</p>

<p>I tried to play around with EnumChildWindow() function but that did not help.  I'd be very appricated if anyone able to point me in the right direction of trying to get this to work?</p>
