user12381459
user12381459

Reputation:

What's the relationship between SID_STopLevelBrowser and IWebBrowser2?

In Raymond's demonstration of how to hop around some shell objects, he first obtains an IWebBrowser2 (or technically IWebBrowserApp), and then uses QueryService to get to SID_STopLevelBrowser. I was wondering if anyone can explain conceptually what those two things are and how they're related. Is one inside the other within an Explorer window? Thanks for any info.

Upvotes: 1

Views: 454

Answers (1)

Anders
Anders

Reputation: 101746

SID_STopLevelBrowser is just a GUID telling QueryService (in this case) which hierarchy object you are interested in. What you are really asking about is; what is the difference between IWebBrowser and IShellBrowser.

IWebBrowser is a Internet Explorer object but when Explorer.exe gained web support in Win98/IE4, a plain Explorer.exe also gained the ability to host web pages (this ability was disabled/deprecated in Vista). The top level (SID_STopLevelBrowser) IShellBrowser on the other hand is the classic "host" object that hosts IShellView (the file list in all versions of Explorer):

Implemented by hosts of Shell views (objects that implement IShellView). Exposes methods that provide services for the view it is hosting and other objects that run in the context of the Explorer window.

Users of Windows 95 could choose to install IE4 without the shell update and on those systems there is full separation between Explorer and Internet Explorer.

Raymond asks for this other browser object because he needs to call IShellBrowser::QueryActiveShellView to gain access to the shell view and the world of IShellFolders and PIDLs.

You can think of IShellBrowser as the host/container of IWebBrowser and/or IShellView but keep in mind that IShellView can be implemented by 3rd-parties when you are in special namespace folders and IShellBrowser can be implemented by 3rd-party file explorer applications so you can't really say that IWebBrowser and the other parts of a Explorer window are tightly connected.

When QueryService does not know the service you are asking for, it is allowed to ask its client-site/host/"parent"/"child". If you want to get the "main" view instance you ask for SID_STopLevelBrowser. Similarly, you can ask the top level browser for SID_SShellBrowser to get the current tab in IE7+.

Upvotes: 1

Related Questions