Website info
More info/contact
Unique visitors: 270181
Copyright 1999 - 2017
Bak-O-Soft (Poul Bak)
Rewards
Host
Hosted by:
PBFolderDialog tips & tricks
Using shellfolders

Using shellfolders gives you a unique way of working with folders on all computers without knowing the actual path at designtime. Shellfolders are system defined paths that vary from computer to computer and from user to user. Using shellfolders is one of the requirements for getting the 'Designed for Windows...' logo.

The most well-known shellfolders are propably the 'MyDocuments' folder and of course the 'Windows' folder. The 'Windows' shellfolder is where windows itself is installed - often 'C:\Windows' or 'C:\WinNT'. The 'MyDocuments' folder is a per-user shellfolder (each user has his/her own path). - often path is 'C:\MyDocuments', 'C:\Documents and settings\%Username%\MyDocuments' or 'C:\Windows\Users\%UserName%\MyDocuments'.

PBFolderDialog can automatically resolve shellfolder-paths and even subfolders to shellfolders. This is done using the syntax: '%CSIDL_WINDOWS%' - the names of shellfolders can be found in help-file.

A shellfolderpath like '%CSIDL_PERSONAL%\MyFolder' will be resolved to for instance: 'C:\Dokumenter\MyFolder'. If the shellfolder doesn't exist, it will be created when browsing (to browse a folder it must obviously exist).

PBFolderDialog always returns the actual path to the folder the user selected - ready for use in your code!

PBShellFolders unit provides functions to work with shellfolders. To save a folder in an Ini-file that might be used by another user or at another system, you can use the 'BuildShellFolderPath' function. In the above example, giving 'C:\Dokumenter\MyFolder' as argument will return '%CSIDL_PERSONAL%\MyFolder' ready for use by another user/system. When reading the ini-file you can translate to an actual path by using the 'ExpandShellFolderPath' function.