Windows API - Finding the handle of an owning window


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?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

saltedAuthor Commented:
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.
saltedAuthor Commented:
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
saltedAuthor Commented:
Dan7el - you genius!

Working like a dream :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.