Click here to Skip to main content
15,884,388 members
Articles / Web Development / HTML
Article

Namespace Extensions: the IDelegateFolder mystery

Rate me:
Please Sign up or sign in to vote.
4.86/5 (4 votes)
15 Feb 20022 min read 97.6K   28   16
Documentation for the undocumented interface IDelegateFolder

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 HKEY_CLASSES_ROOT\ftp.

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.

Using 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 IDelegateFolder:

// {ADD8BA80-002B-11D0-8F0F-00C04FD7D062}
DEFINE_GUID(IID_IDelegateFolder,
            0xADD8BA80L, 0x002B, 0x11D0, 0x8F, 0x0F, 0x00, 0xC0, 0x4F, 0xD7, 0xD0, 0x62);

This is the interface definition:

DECLARE_INTERFACE_(IDelegateFolder, IUnknown)
{
	// IUnknown methods
	STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
	STDMETHOD_(ULONG,AddRef)(THIS)  PURE;
	STDMETHOD_(ULONG,Release)(THIS) PURE;

	// IDelegateFolder methods
	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 IMalloc
  • 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 (0x61 0x03).

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.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Belgium Belgium
Henk studied computer science at the University of Ghent, specializing in theoretical computer science.
He is now working for Artwork Systems, Belgium, and Whirling Dervishes Software, Belgium.
Henk knows a little something about networking, graphics, object-oriented design, AI, embedded systems. He knows most of the PDF specs by heart.
Henk developed NSELib, the NameSpace Extension Library.
You can find his latest freeware software at regxplor.com. It contains a namespace extension that puts the registry in Windows Explorer. The newest commercial project is Alpha ZIP, an explorer-embedded ZIP file utility.

Comments and Discussions

 
QuestionUsing a namespace extension with a custom protocol Pin
be mo22-Jun-06 21:50
be mo22-Jun-06 21:50 
QuestionHow to add namespace extensions to the backup window, so I can backup. Pin
greenjade8009-Aug-04 13:26
greenjade8009-Aug-04 13:26 
Generaloffset Pin
Anonymous27-Jul-04 20:02
Anonymous27-Jul-04 20:02 
GeneralRe: offset Pin
Henk Devos27-Jul-04 22:32
Henk Devos27-Jul-04 22:32 
QuestionHow I display the background directory context menu? Pin
Miguel Matos1-Oct-03 1:10
Miguel Matos1-Oct-03 1:10 
AnswerRe: How I display the background directory context menu? Pin
Henk Devos1-Oct-03 1:36
Henk Devos1-Oct-03 1:36 
GeneralRe: How I display the background directory context menu? Pin
Miguel Matos1-Oct-03 5:07
Miguel Matos1-Oct-03 5:07 
GeneralIDelegateFolder not registered in W2K Pin
ayeka27-May-03 20:42
ayeka27-May-03 20:42 
GeneralRe: IDelegateFolder not registered in W2K Pin
Henk Devos27-May-03 21:31
Henk Devos27-May-03 21:31 
Generaljust curious... Pin
umeca7413-Oct-02 0:12
umeca7413-Oct-02 0:12 
GeneralRe: just curious... Pin
Henk Devos13-Oct-02 7:33
Henk Devos13-Oct-02 7:33 
Question(where is) API defn for my own protocol handler? Pin
Relishguy19-Mar-02 10:39
Relishguy19-Mar-02 10:39 
AnswerRe: (where is) API defn for my own protocol handler? Pin
Relishguy19-Mar-02 13:43
Relishguy19-Mar-02 13:43 
GeneralRe: (where is) API defn for my own protocol handler? Pin
Henk Devos22-Mar-02 7:06
Henk Devos22-Mar-02 7:06 
QuestionWhy root there? Pin
_Magnus_18-Feb-02 4:09
_Magnus_18-Feb-02 4:09 
AnswerRe: Why root there? Pin
Henk Devos18-Feb-02 4:13
Henk Devos18-Feb-02 4:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.