-2

I am trying to open a dialog box where the user selects a certain folder on pure C++, no .Net framework or C#, and am struggling to find how the lpstr would filter everything but directories. I am currently using the OPENFILENAME function. I tried filtering to .dir, but it does not work. Anyone know the actual extension or any solutons?

  • Guessing you should tag this for winapi. The common file dialog box isn't really designed for selecting directories. Have a look at `SHBrowseForFolder` instead. – Jonathan Potter Jan 23 '22 at 06:02

2 Answers2

0

The OPENFILENAME struct is used with the old GetOpenFileName() Common Dialog Box, which can't be used to select a folder. It is simply not designed for that purpose.

You need to use SHBrowseForFolder() instead, or in Vista+ you can (and should) use the newer IFileOpenDialog Common Item Dialog with the FOS_PICKFOLDERS option enabled.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770