We help IT Professionals succeed at work.

Windows API - Finding the handle of an owning window

salted asked
Medium Priority
Last Modified: 2008-02-01

I've got an instance of InternetExplorer on a new thread running in my app, and, using IE.HWND I am trying to get the handle of the IE window including all the chrome, however, IE.HWND only gives me the handle for the document itself and the status bar for some reason.

I've tried this:

[DllImport("user32.dll", ExactSpelling = true, CharSet = CharSet.Auto)]
public static extern IntPtr GetWindow(IntPtr hWnd, int uCmd);
public const int GW_HWNDFIRST = 0;

hwnd = (IntPtr)GetWindow(hwnd, GW_HWNDFIRST);

But it's returning a IntPtr with the value of 0.

Anyone now how to go up enough to get the actual full window - it's classname is "IEFrame" - and i've tried using that to get it, but it did the same, and even if it did work, it doesn't garauntee it will get the right instance of IE (i don't want to search by WindowTitle/Name)

public static extern IntPtr FindWindow(string sClassName, string sWindowName);


hwnd = FindWindow("IEFrame", string.Empty);

Is there another Windows API function I can import?
Watch Question


Sorry - just to add, I tried manually spying the handle for the full window of an instance of IE and putting that in the app and it worked perfectly. So i know that's what i'm after. I just can't seem to get that handle at run-time.


hehe, sorry, one more thing i just thought of - it's IE7 Beta 2 Preview that is installed on this machine - although from when i was doing this with IE6 it doesn't seem to make much difference. I need it to work with IE7 - I can't be certain, but i'm pretty sure IE6's chrome window had a classname of "IEFrame" as well.
Independent Consultant

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


Dan7el - you genius!

Working like a dream :)
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.