Easy Browse for Folder with MFC

SHBrowseForFolder shell API function shows a dialog which allows users to select a folder. As can be seen in MSDN documentation or other examples, it requires pretty much additional code around, so you would prefer to write your own wrapper in order to reuse code along applications. But luckily, MFC library has that wrapper already done.

Browse for folder using MFC

All you have to do is the following:

  1. derive your application class from CWinAppEx;
  2. whenever you want to show a “browse for folder” dialog
    • call CWinAppEx::GetShellManager to get a pointer to a global CShellManager object then
    • call CShellManager::BrowseForFolder.

A simple example of using CShellManager::BrowseForFolder


  • CWinAppEx as well as CShellManager classes were introduced with MFC Feature Pack. That means you need Visual Studio 2008 or newer;
  • CShellManager::BrowseForFolder has additional default parameters which can be used for more customization;
  • a little bit more complete example can be found in the demo application.

MFC Browse For Folder demo application

Download: MFC BrowseForFolder Demo.zip (1756)

MFC BrowseForFolder demo application

MFC Browse For Folder demo application

Resources and related stuff

One thought on “Easy Browse for Folder with MFC

Leave a Reply