title: Why is FindWindow() not 100% reliable?
body: <p>I'm using this Delphi 7 code to detect if Internet Explorer is running:</p>
  
  <pre><code>function IERunning: Boolean;
  begin
    Result := FindWindow('IEFrame', NIL) &gt; 0;
  end;
  </code></pre>
  
  <p>This works on 99% of the systems with IE 8,9 and 10.</p>
  
  <p>But there are some systems (unfortunately none of mine, but I have two beta testers which have such systems, both Win7 x64 SP1) where FindWindow() returns 0 for IEFrame, even if IE is in memory.</p>
  
  <p>So I've coded an alternate method to find the window:</p>
  
  <pre><code>function IERunningEx: Boolean;
  var WinHandle : HWND;
      Name: array[0..255] of Char;
  begin
    Result := False; // assume no IE window is present
  
    WinHandle := GetTopWindow(GetDesktopWindow);
  
    while WinHandle &lt;&gt; 0 do // go thru the window list
    begin
        GetClassName(WinHandle, @Name[0], 255);
        if (CompareText(string(Name), 'IEFrame') = 0) then
        begin // IEFrame found
            Result := True;
            Exit;             
        end;
        WinHandle := GetNextWindow(WinHandle, GW_HWNDNEXT);
    end;      
  end;
  </code></pre>
  
  <p>The alternate method works on 100% of all systems.</p>
  
  <p>My question - why is FindWindow() not reliable on some of the systems?</p>