Since Internet Explorer 4, the shell namespace contains an "Internet Explorer" item.
This Internet Explorer forms a special junction point where you can include your own namespace extensions.
Microsoft uses this for their FTP folders. You can add your own by registering a url prefix in the registry. Copy the entries that are used in
However, something strange is going on. You don't see the root item of this namespace extension displayed in explorer. There is no item named "ftp folders" that is the root of all ftp folders. Instead, the "Internet Explorer" item functions as the root.
This has a very strange implication: The Internet Explorer root item had to understand the pidls of all underlying namespaces.
The solution: Internet Explorer will embed the pidls of all namespace extensions in its own pidls. The mechanism used to accomplish this is
IDelegateFolder, your namespace extension will receive an
IMalloc interface. The
Alloc function of this
IMalloc will allocate an Internet Explorer pidl that points to your namespace extension and has empty room to put your own pidl in.
This is the IID of
0xADD8BA80L, 0x002B, 0x11D0, 0x8F, 0x0F, 0x00, 0xC0, 0x4F, 0xD7, 0xD0, 0x62);
This is the interface definition:
STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
STDMETHOD(SetItemAlloc)(THIS_ IMalloc *pMalloc) PURE;
After instantiating your namespace extension, Internet Explorer will query for the
IDelegateFolder interface and call
SetItemAlloc, passing an
IMalloc interface. You have to store this interface.
From this moment on, when ever you have to create a pidl, you have to follow these steps:
- Call the
Alloc function of this
- Insert your own complete pidl (including the size) at offset 4 of the returned buffer
- Return this buffer as your own pidl
The returned buffer will already be a pidl, starting with the size (2 bytes) and then a 2 bytes signature (
All the pidls that will be passed to your namespace extension will also have this format. This means you will find your own pidl at offset 4.
The pidls are still freed the normal way, using the shell allocator.
If your namespace extensions has subfolders, then these subfolders follow the normal system. The first id in the list will be the special Internet Explorer pidl, all the others that follow are your own normal pidls.
This is not a clean solution that was chosen by Microsoft. It would have been much easier if the Internet Explorer root node would do the insertion and extraction of the embedded pidl, eliminating the need for this interface.