This is a mirror of official site: http://jasper-net.blogspot.com/

Namespace extensions - the undocumented Windows Shell

| Wednesday, February 24, 2010
This article explains how you can easily create a namespace extension with lots of features without doing lots of work by using some undocumented shell functions. The most noticeable function is SHCreateShellFolderViewEx, which creates the view for you and creates all interfaces you need for displaying the contents of your folder. You can modify the behaviour of the folder by implementing a callback function. This is how Microsoft implements its own namespace extensions.
Introduction to the windows shell

The windows shell is built around COM interfaces. The browser ("explorer") calls interfaces that are implemented by a number of DLL's and these DLL's can call back into the interfaces of the browser. You can extend the behaviour of the browser by plugging in your own DLL that implements the needed interfaces.

The householding of the DLL's is maintained in the registry, as is usual for COM objects.
The shell namespace

The shell namespace is a collection of folders that contain items. These items can in turn be folders, generating a tree structure. This ressembles the directory tree structure that is found in a file system, but should not be confused with it.

The top of the shell namespace tree is the Desktop folder. This folder contains "my computer", which in turn contains the drives on your computer. The part of the shell namespace that represents a drive looks almost the same as the directory structure on that drive, but is not exactly the same. The drive can contain additional items and existing items may look very different in the shell namespace.
Shell extensions

The DLL's that are plugged into the shell are called shell extensions. There are several kinds of shell extensions:

  1. A context menu extension puts extra items in the context menu that is viewed in the browser.
  2. A property sheet extension displays extra property pages in the property sheets that are viewed in the browser.
  3. A namespace extension adds extra folders to the namespace.

Pidls

Every item in a folder is identified by an identifier, just like every file or directory on a drive is identified by a filename. This identifier is called a Pidl.

For someone who uses the shell to browse the namespace, a pidl is just an opaque structure that gets passed around without having any meaning.

Someone who implements a part of the namespace assigns a meaning to the pidls for his part of the namespace. The pidl is a variable-sized structure that can contain anything the implementor wants to put in. The pidl usually caches all information that is frequently needed. In a directory structure, the pidl contains the long and short filename and some other stuff.

Read more: Codeproject

Posted via email from jasper22's posterous

0 comments: