Customize Places Bar in Common File Dialog

Recently, CodeGuru has published my article about customizing the Places Bar of the common file dialog. In this article I have explained how to twick the registry to display your own list of shortcuts in the places bar.

The folders are specified in registry under HKEY_CURRENT_USER in Software\Microsoft\Windows\CurrentVersion\Policies\ComDlg32\PlacesBar in two ways: either by IDs for a predefined list of folders, or by path. The name of the values must have the form PlaceX, where X is a numerical value. The key specified above does not exist by default. The operating system tries to read it and if it is find, it loads the enumerated places; if the key is missing a default list is displayed. The key affects the entire system, except for the application in the Office suite. To have a Places Bar changed only for a specific application, a temporary modification of the registry can be done, by mapping a temporary key to HKEY_CURRENT_USER with the use of RegOverridePredefKey() API. That basically implies:

  • Creating a temporary key and mapping it for the HKEY_CURRENT_USER
  • Putting the file dialog places there under Software\Microsoft\Windows\CurrentVersion\Policies\ComDlg32\PlacesBar
  • Displaying the file dialog
  • At the end, restoring the predefined HKEY_CURRENT_USER and deleting the temporary key

In the article published on CodeGuru you can read more details about this and see the code of a demo application that I created to explain how things work. The article is available at http://www.codeguru.com/cpp/misc/misc/system/article.php/c13407/.

3 Replies to “Customize Places Bar in Common File Dialog”

  1. This method does work but when implemented as described there are problem.
    Because the entire HKCU is now hidden values needed for other aspects of the dialog don’t appear. For example in my test all the file extensions were gone.
    My work around was to temporarily create my PlacesBar options on the CDN_INITDONE and clear them out on the first CDN_SELCHANGE. This has worked great under XPSP2 and Vista.
    Have you ever implemented your method in a production application?

  2. Hi,

    How to add out custom images for the custom place. instead of placing windows supplied images

    can this be achieved?

    Regards,
    Vishal

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.