Skip over navigation

Shell Folders Unit

Browse for Folder dialogue box & other Windows shell folder handlog code

Version 2.3.2
Released 2014-01-11
Platforms Win32 & Win64
Framework VCL
Compatibilty Delphi 7 and later

Overview

This unit provides various components, classes and routines for handling Windows shell folders. Included are:

TPJBrowseDialog
A component that encapsulates the Windows Browse for Folder dialogue box. This component, which provides a wrapper round theWindows API SHBrowseForFolder function, permits a degree of customisation of the dialogue box.
TPJSpecialFolderInfo
A component that provides information about a specified special shell folder. Information is extracted from the Windows SHGetSpecialFolderLocation function and is presented in a usable form via the component's properties.
TPJSpecialFolderEnum
A class that enumerates all the special shell folders (implements IPJSpecialFolderEnum below).
IPJSpecialFolderEnum
An interface to an object that enumerates all the special shell folders.
Support routines
Various routines are provided that can manipulate special shell folder identifier information and extract display name and path information from PIDLs.
CSIDL_ Constants
Various CSIDL_ constants that are not provided by all versions of Delphi are declared. These identify all known special folders or are flags that can be combined with special folder ids. MSDN provides information about these constants.
Property Editor
A separate design time unit contains a property editor for special shell folder identifiers. This property editor enables the object inspector to display shell folder constant names for relevant properties.

Features of TPJBrowseDialog include:

  • The dialogue's OK button can be enabled or disabled according to the currently selected folder.
  • Status text that changes with the currently selected folder can be displayed. This is done by setting an option and handling the OnSelChange or OnSelChangeEx events.
  • The PIDL of the currently selected folder is made available via the OnSelChangeEx event.
  • Virtual and file system folders can be displayed. The display can also be limited to file system folders only.
  • A help button can be included in the dialogue box that is automatically disabled if the component's HelpContext or HelpKeyword properties are null. An OnHelp event can be used to customise help handling.
  • The dialogue box can be customised by handling the OnInitialise event.
  • The "New style" of Browse for Folder dialogue box can be displayed by setting an option. Such a dialogue box is resizeable and can display a Make New Folder button. Status text and the Help button cannot be displayed in the new style dialogue box.
  • Hints on using the dialogue box can be displayed.
  • An edit control in which folder names can be entered can be displayed and actions taken when invalid folders are entered can be customised.

A demo program is provided. It lists and provides information about all the special shell folders supported by the unit. A read-me file is included with the demo that explains further.

Get The Code

You can download the latest version of the Shell Folders Unit directly from SourceForge as dd-shellfolders-2.3.2.zip.

Download v2.3.2

The Shell Folders Unit source code is hosted in the ddablib/shellfolders GitHub repository. You can git clone or fork the repository as required.

Installation

The Shell Folders Unit, its property editor, documentation and demo program are supplied in a zip file. Before installing you need to extract all the files from the zip file, preserving the directory structure. The following files will be extracted:

  • PJShellFolders.pas – classes, routines, constants and component source code.
  • PJShellFolders.dcr – component palette glyphs.
  • PJShellFoldersDsgn.pas – property editor and component registration source code.
  • ReadMe.htm – read-me file.
  • ChangeLog.txt – unit's change log.
  • MPL-2.txt – the Mozilla Public License v2.0.
  • Documentation.URL – short-cut to the unit's online documentation.
  • PJShellFolders.hlp – help file that integrates with the Delphi 3-7 OpenHelp system. Deprecated
  • PJShellFolders.als – a-link keyword file for integration with the Delphi 6 or 7 OpenHelp system. Deprecated

In addition to the above files you will find the source code of a demo project in the Demo sub-directory.

You can now install the components into the Delphi IDE. To do this, the files PJShellFolders.pas, PJShellFolders.dcr and PJShellFoldersDsgn.pas should be added to a design time package. If you need help doing this see here.

Documentation

The Shell Folders Unit is comprehensively documented online here

The project's change log can be viewed here.

A read-me file (ReadMe.htm) is included in the project download.

A legacy WinHelp help file is included in the download that can only be integrated with the IDE in Delphi 7 and earlier. This article explains how to do it.

This help file is deprecated and is no longer being updated. The last update was in the v2.3.1 release. The help file will be removed from any future release.

WinHelp is an optional download for Windows Vista through to Windows 8.1 and can't be installed at all on Windows 10 and later.

Feedback & Queries

If you find any bugs or want to suggest a new feature please report them using the Shell Folders Unit issue tracker.

If you have created a bug fix or have implemented a new feature please open a pull request for it.

Should you have any queries about using the unit please read the documentation. If you can't find an answer in the documentation then post a message in the discussion group.

License

The Shell Folders Unit is open source. It is copyright © 2001-2014 by Peter Johnson. The source code is made available under the terms of the Mozilla Public License v2.0. All relevant trademarks are acknowledged.