Displaying a Self-Contained View of a Namespace Extension

Most namespace extensions are a subset of the Shell namespace. When you create a junction point, as described in Specifying a Namespace Extension's Location, Microsoft Windows Explorer allows users to navigate into and out of your namespace extension just like any other folder. However, it is also possible to use Windows Explorer to display only the contents of your namespace extension. This display option is sometimes referred to as a rooted view. Although not commonly used, rooted views might be preferable to normal views for some types of extensions.

With a rooted view, a new instance of Windows Explorer is created that displays the contents of the extension as a separate namespace. The tree view of a rooted view shows only those folders that are part of the extension. Users cannot navigate from a rooted view to other parts of the Shell namespace.

Extensions are implemented in the same way for rooted views as they are for normal views. The only difference is in the way the contents of the extension are displayed by Windows Explorer. It is even possible to have normal and rooted views of the same extension.

To open a view of an extension, you must launch an instance of Explorer.exe with a /root flag. There are several different ways to launch a rooted view, depending on the nature of your extension.

Using a Junction Point to Open a Rooted View

Typically, clicking or double-clicking the folder that represents a junction point opens a normal view of the contents of the associated extension. However, you can use the registry to specify that browsing into a junction point will open a rooted view. To do so, add Open and Explore command keys to your extension's CLSID registry key.

    • CLSID
      • {Extension CLSID}
        • Shell
          • Open
            • Command

            • (Default) = %SYSTEMROOT%\explorer.exe/e,/root,"%1"
          • Explore
            • Command

            • (Default) = %SYSTEMROOT%\explorer.exe/e,/root,"%1"

When the user clicks or double-clicks the junction point, an instance of Explorer.exe is launched to display the contents of the extension as a rooted view.

Using a Shortcut File to Open a Rooted View

Another approach to launching a rooted view is to create a shortcut file and set the command to Explorer.exe with a /root flag. The exact form the command takes depends on the location of the junction point:

  • If the junction point is a subfolder of the Desktop, use:
    Explorer.exe /e,/root,::{Extension CLSID}
  • If the junction point is a file system folder, use:
    Explorer.exe /e,/root,[Fully qualified path to the folder]
  • If the junction point is a subfolder of a system virtual folder, use:
    Explorer.exe /e,/root,::{Folder CLSID}\::{Extension CLSID}

The system virtual folders that can contain junction points have the following class identifier (CLSID)s.

My Computer {20D04FE0-3AEA-1069-A2D8-08002B30309D}
My Network Places {208D2C60-3AEA-1069-A2D7-08002B30309D}
Control Panel {21EC2020-3AEA-1069-A2DD-08002B30309D}
Internet Explorer {871C5380-42A0-1069-A2EA-08002B30309D}
Note  Systems earlier than Windows 2000 use a display name of Network Neighborhood instead of My Network Places. However, the CLSID is the same for both.

Displaying a Rooted View of a File

Extensions are usually presented to the user as a folder. However, you can also use an extension to allow users to browse the contents of a file. Extensions of this sort are typically used to display the contents of the members of a file class. For instance, the members of a file class might contain multiple compressed files or images, organized in a hierarchy. Rather than write an application to allow the user to view the contents of such a file, you can instead write a namespace extension and let Windows Explorer handle the display.

You must use a rooted view to have an extension display the contents of a file. The most common way to provide a rooted view of the members of the file class is to define a shortcut menu verb that launches an instance of Explorer.exe. By making this verb the default verb, a double-click will also open a rooted view of the file. You can either define a verb for all members of the file class by modifying the registry, or dynamically define verbs on a file-by-file basis by implementing a shortcut menu handler.

The following example illustrates how to use the registry to provide a rooted view of the members of a file class by modifying the registry. The sample registry entry is a modification of one of the examples in Extending Shortcut Menus. The registry entries define files with an .myp file name extension as a file class, and use the browse verb to launch a rooted view of members of that class.

    • .myp

    • (Default) = MyProgram.1
    • MyProgram.1

    • (Default) = MyProgram Application
      • Shell

      • (Default) = browse
        • browse
          • command

          • (Default) = %SYSTEMROOT%\explorer.exe /e,/root,{Extension CLSID}, "%1"

You can use the same verb to programmatically launch a rooted view of a member of the file class by calling ShellExecute.

Community Additions