Desktop Icon for Default Web Browser

Most Windows users are by now familiar with Microsoft’s provisions for making Internet Explorer’s presence in Windows less apparent and for emphasising the user’s preference for a different web browser. Critical attention, even extending to legal proceeedings, has tended to focus on an Internet Explorer icon which Windows used to place on the desktop by default (and still does, once you have chosen the Classic Start Menu). This icon is especially notable for having no shortcut overlay, so that it looks more fundamental than most, as if it’s an entirely natural addition to the desktop icons for system folders such as the Computer, Control Panel or Network.

Of course, no browser, seen just as one of many competing web-browser applications, is any sort of system resource. However, an abstracted notion of access to the Internet, without caring which particular web browser happens to be installed or preferred, arguably is a system resource and might usefully be represented by a desktop icon that looks like a system object. It could look like this:

Windows Vista Desktop Icons (Internet Explorer)

or this:

Windows Vista Desktop Icons (Firefox)

depending on your choice of default web browser.

Exactly such a system object already exists. Indeed, you very likely have used it at least once: when you first start Windows, the Start Menu typically has at its top a shortcut to this abstracted Internet object. Choose a different browser as the default and this shortcut changes too. You can drag this shortcut to the desktop, but what results is still a shortcut to the underlying object. If you want the Internet on the desktop as a system object, as in the pictures, you can have it just by adding one registry key:

Key: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace
Subkey: {2559A1F4-21D7-11D4-BDAF-00C04F60B9F0}

Adding to the first of the keys, under HKEY_LOCAL_MACHINE, is typically easier because the key exists already. However, it has the effect of adding the icon to the desktop for all users. This may be what you want, but if not, add to the HKEY_CURRENT_USER branch even though you may have to build the tree before you can add the subkey.

After adding the key (and possibly also if you change your default browser, depending on how you do it), you will typically have to refresh the desktop to get the key noticed or the icon redrawn. Just click on the desktop and press F5.

Explanation

The numbers in curly braces are the class ID (CLSID) for the Internet object. That you can add it to the desktop’s namespace and have it work immediately is because Windows is installed with a set of suitable registry entries for this class ID. These registry entries rely on other types of object which are supported by executable code. For it all to work, you need at least SHDOCVW.DLL version 5.00 and SHELL32.DLL version 6.00. In practice, then, you need Windows XP or higher.

The essential SHELL32 support is for the ClientExtractIcon and AssocClientElement classes (neither of which is documented). The latter provides access to the registry key where competing browsers are configured. Of particular importance is the determination of the default browser. It is found from the default value of the following registry keys (in decreasing order of precedence):

Key: HKEY_CURRENT_USER\Software\Clients\StartMenuInternet
HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet
Value: default
Type: REG_SZ

Provided that the REG_SZ data is non-empty (and does not exceed 80 characters), it names the default StartMenuInternet client, i.e., the default web browser. What is then knowable about the default browser all comes from subkeys and values in the one registry key:

Key: HKEY_LOCAL_MACHINE\Software\Clients\StartMenuInternet\DefaultBrowser

Beware that the behaviour of the Internet icon (and of the equivalent Start Menu shortcut) is only as good as the information that the browser’s setup program has recorded in this key. Some manufacturers are suprisingly unimaginative in their interpretation of Microsoft’s admittedly perfunctory documentation of what to put in this key. For instance, though Microsoft documents that the command to start the browser needs to be the default value of a subkey named shell\open\command, there is no explicit direction that verbs other than “open” can be meaningful. Unless the browser supplies a command under shell\properties\command, the context menu for the icon (or Start Menu shortcut) defaults to showing Internet Properties, as if for Internet Explorer.

The ClientExtractIcon class can expose any type of association element as a shell extension. To specify an association with the default web browser as a type of client program requires more configuration. For this configuration to come through registry settings, the class is created as an SHDOCVW instance class. This is why the CLSID key for the Internet object has SHDOCVW.DLL as its InProcServer32. This has a curious implication, given that SHDOCVW is the essence of Internet Explorer in versions before Windows Vista: to start a non-Microsoft web browser from the Internet shortcut on the Start Menu, you actually depend on running a little bit of Internet Explorer.

An instance class provides a sort of CLSID redirection. What you actually get when creating an instance is specified in the Instance subkey for the CLSID. In particular, the following value specifies that the instance class for the Internet object is actually to be a ClientExtractIcon:

Key: HKEY_CLASSES_ROOT\CLSID\{2559a1f4-21d7-11d4-bdaf-00c04f60b9f0}\Instance
Value: CLSID
Type: REG_SZ
Data: {25585dc7-4da0-438d-ad04-e42c8d2d64b9}

The data is the string representation of CLSID_ClientExtractIcon. How the ClientExtractIcon class is to be configured comes from properties in a deeper subkey named InitPropertyBag. That it should expose an AssocClientElement class is because the data for the value

Key: HKEY_CLASSES_ROOT\CLSID\{2559a1f4-21d7-11d4-bdaf-00c04f60b9f0}\Instance\InitPropertyBag
Value: Element
Type: REG_SZ
Data: {3c81e7fa-1f3b-464a-a350-114a25beb2a2}

is CLSID_AssocClientElement. The particular type of client to be modelled by the AssocClientElement is specified through the InitString value:

Key: HKEY_CLASSES_ROOT\CLSID\{2559a1f4-21d7-11d4-bdaf-00c04f60b9f0}\Instance\InitPropertyBag
Value: InitString
Type: REG_SZ
Data: StartMenuInternet

There are more settings involved, both to configure the ClientExtractIcon class and for the object to have an icon and context menu, but the settings shown above are the ones that join the dots for the selection of a default web browser.

Note that the scheme works for other types of client program. For instance, if you wanted a desktop icon for the default media player, you could generate a new CLSID to take the place of {2559A1F4-21D7-11D4-BDAF-00C04F60B9F0}, and then reproduce all the subkeys and values but set Media as the data for the InitString value.

E-Mail

In the particular case of e-mail readers, there is a set of subkeys and values defined already. So, if you want a desktop icon to represent your default e-mail reader, just add to the desktop’s namespace as if for the default web browser but change the CLSID to {2559A1F5-21D7-11D4-BDAF-00C04F60B9F0}.