Displays a dialog box that enables the user to select a shell folder.
LPITEMIDLIST SHBrowseForFolder(
LPBROWSEINFO lpbi
);
Returns a pointer to an ITEMIDLIST structure (PIDL) that specifies the location of the selected folder relative to the root of the namespace. If the user chooses the Cancel button in the dialog box, the return value is NULL.
You must initialize COM with CoInitialize or OLEInitialize prior to calling SHBrowseForFolder.
The calling application is responsible for freeing the returned PIDL with the shell allocator's IMalloc::Free method. To get a handle to the shell allocator's IMalloc interface, call SHGetMalloc. See The Shell Namespace for further discussion of the shell allocator and PIDLs.
There are two styles of dialog box available. The older style is displayed by default, and is not resizable. To specify a new-style dialog box set the BIF_USENEWUI flag in the ulFlags member of the BROWSEINFO structure. It has a number of additional features, including: drag and drop capability within the dialog box, reordering, context menus, new folders, delete, and other context menu commands. Initially, it is larger than the old dialog box, but can be resized by the user.
If you implement a callback function, you will receive a handle to the dialog box. One use of this window handle is to modify the layout or contents of the dialog box. Because it is not resizable, modifying the old-style dialog box is relatively straightforward. Modifying the new-style dialog box is much more difficult, and not recommended. It not only has a different size and layout than the old style, its dimensions and the positions of its controls change every time it is resized by the user.
If the BIF_RETURNONLYFSDIRS flag is set in the ulFlags member of the BROWSEINFO structure, the OK button will remain enabled for "\\server" items, as well as "\\server\share" and directory items. However, if the user selects a "\\server" item, passing the PIDL returned by the dialog box to SHGetPathFromIDList will fail.
Open and Save Common Dialog Boxes
Version 4.00 and later of Shell32.dll
Windows NT/2000: Requires Windows NT 4.0 or later.