ShellBrowser Delphi Components Documentation
ContentsIndexHome
PreviousUpNext
The Shell Namespace

The Shell Namespace 

This is a short introduction to the Windows shell name space which may be of interest for advanced users. 

 

The Windows shell uses a single hierarchical name space to organize all objects such as files, storage devices, printers, network resources and anything else that can be viewed using the Explorer. The root of this unified name space is the Windows desktop. While similar to a file system's directory structure, the name space contains more types of objects then just files and directories. 

 

Shell Folders 

 

Windows uses a data structure that represents the hierarchy of objects all the way from the desktop to every item that can be seen in the Explorer. From the desktop you can get to drives, Control Panel, Printers and Dial-UP Networking. Look at the left pane of the Explorer to see the hierarchy of objects clearly. These items are called virtual folders, virtual because they refer to items in the name space that can contain other name space items, as opposed to groups of files. An application can use shell functions to retrieve the locations of these special folders. 

 

Because there are many kinds of folders and file objects, each folder is an OLE component object model (COM) object that can enumerate its contents and carry out other actions. More precisely, each folder implements the IShellFolder interface. Retrieving the IShellFolder interface for a shell folder is referred to as binding to the folder. 

 

Item Identifiers / PIDLs 

 

Objects in the shell namespace are represented by item identifiers and item identifier lists. An item identifier uniquely identifies an item within its parent folder. An item identifier list uniquely identifies an item within the shell namespace by tracing a path to the item from a known point - usually the desktop. A pointer to an item identifier list (PIDL) is used throughout the shell to identify an item. 

 

Item identifiers (often referenced as PIDLs) are much like the file names and paths, respectively, used in a file system. However, they share this important difference: item identifiers are binary data structures that never appear to the user. However there are functions to retrieve display names from an Item Identifier or an Item Identifier List that may be presented to the user. 

 

Besides ShellFolders and ItemIdLists there are many other interfaces, that Windows provides to connect and interact with the Windows Shell. 

 

In depth information can be found on Microsoft docs, e.g. Introduction to the Shell Namespace

 

 

ShellBrowser components 

 

ShellBrowser makes use of many of these Windows Shell interfaces. Most of it goes on under the hood inside the components, without the need having to deal with the respective APIs explicitly. 

 

You might have use-cases though where instead of using normal system file paths, you will want to work with the PIDL type of item identifier instead. 

 

ItemIdLists in ShellBrowser 

 

ShellBrowser hosts an Item Identifier via the class TJamItemIdList, or the interface IItemIdList respectively (the class is typcially only used for creation). The type not only handles the PIDLs but comprises other shell interfaces needed for additional functionality. 

 

The IItemIdList type is used by all components in ShellBrowser. Most of them accept paths both as a normal File System Path as string, as well as IItemIdList. 

 

Example: 

 

Using TJamShellList.Path, you can set the folder that should be displayed. You can achieve the same using 

 

  shellList.FolderIdList = TJamItemIdList.Create(path);

 

The advantage of the ItemIdList is that it also supports virtual elements that do not have a physical path: 

 

  shellList.FolderIdList := TJamItemIdList.CreateForSpecialFolder(TJamShellFolder.SF_QUICKACCESS); //opens "Quick Access"

 

 

But you can also use the ItemIdList "standalone", e.g. to retrieve file information. 

 

Example: 

 

The following line gets the artist stored in some mp3 file: 

 

lInfo := TJamItemIdList.Create(pathToMp3File).GetShellInformation([TShellColumns.Music_Artist, TShellColumns.Music_AlbumTitle]);

 

It's also possible to set values. The following example sets the artist for the selected items in a TJamShellList

 

  for lItemIdList in shellList.GetSelectedElements() do begin
    lItemIdList.SetPropertyValue(TShellColumns.Music_Artist, 'Nirvana');
  end;

 

For more information on the ItemIdList class please see the API-documentation of ShellBrowser Delphi components.