Win32 - Select Directory Dialog from C/C++

Viewed 40802

How to select an existing folder (or create new) from a native Win32 application?

Here is a similar question. It has a good answer for C#/.NET. But I want the same thing for native Win32.

Anybody knows a solution, free code, etc?

Update:

I tried the function from the answer. Everything worked as expected, except it is necessary to call the SHGetPathFromIDList function to retrieve the name of selected directory. Here is a sample screen shot:

Example of the directory pickup dialog.

3 Answers

For Windows Vista and above, it's best to use IFileOpenDialog with the FOS_PICKFOLDERS option for a proper open dialog rather than this tree dialog. See Common Item Dialog on MSDN for more details.

Related