GetFolder : Shell Extension Folder Browser Function
Posted
by Vishal D. Khapre
on February 13th, 2001

Folder browser dialog - also enumerates network drives...
...demo application shows how easy it is to display dialog and retrieve user-selected folder.
Overview
This is a very standard technique used to retrieve folder information from Windows using the Shell extension functions SHBrowseForFolderA, SHGetPathFromIDList and SHGetDesktopFolder.The Code
All you need to do is to call my function GetFolder. However, for the more curious among you that want to know more of the details, there are only two functions used here: one to cause the display of the standard folder browser dialog and a callback function that handles the processing of events while the dialog is being displayed). Here are the basic steps in my code.
GetFolder Steps
- Call SHGetDesktopFolder to get the IShellFolder interface for the desktop folder
- Call the IShellFolder.ParseDisplayName to get the identifier list
- Allocate and fill out a BROWSEINFOA structure with the desired parameters (e.g., pidl from the IShellFolder.ParseDisplayName, callback function that the shell will call with the folder names, etc.). The callback function is called BrowseCallbackProc.
- Call SHBrowseForFolderA to display the folder browse dialog (passing it the BROWSEINFOA structure which defines how that dialog should appear)
- Upon return from the SHBrowseForFolderA function, I then call the SHGetPathFromIDList function in order to retrieve the name of the user-selected folder.
Comments