Displays a dialog box that enables the user to select a Shell folder.

SHBrowseFolder(cTitle, nFlags, @cPath [, cRootPath [, cCallback]])

Parameters

cTitle

A string that is displayed above the tree view control in the dialog box. This string can be used to specify instructions to the user.

nFlags
Flags that specify the options for the dialog box. This parameter can be 0 or a combination of the following values.
FlagMeaning
BIF_RETURNONLYFSDIRSOnly return file system directories. If the user selects folders that are not part of the file system, the OK button is grayed.
Note The OK button remains 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 SHBrowseForFolder to SHGetPathFromIDList fails.
BIF_DONTGOBELOWDOMAINDo not include network folders below the domain level in the dialog box's tree view control.
BIF_STATUSTEXTInclude a status area in the dialog box. The callback function can set the status text by sending messages to the dialog box. This flag is not supported when BIF_NEWDIALOGSTYLE is specified.
BIF_RETURNFSANCESTORSOnly return file system ancestors. An ancestor is a subfolder that is beneath the root folder in the namespace hierarchy. If the user selects an ancestor of the root folder that is not part of the file system, the OK button is grayed.
BIF_EDITBOXInclude an edit control in the browse dialog box that allows the user to type the name of an item.
BIF_VALIDATEIf the user types an invalid name into the edit box, the browse dialog box calls the application's BrowseCallbackProc with the BFFM_VALIDATEFAILED message. This flag is ignored if BIF_EDITBOX is not specified.
BIF_NEWDIALOGSTYLEUse the new user interface. Setting this flag provides the user with a larger dialog box that can be resized. The dialog box has several new capabilities, including: drag-and-drop capability within the dialog box, reordering, shortcut menus, new folders, delete, and other shortcut menu commands.
BIF_BROWSEINCLUDEURLSThe browse dialog box can display URLs. The BIF_USENEWUI and BIF_BROWSEINCLUDEFILES flags must also be set. If any of these three flags are not set, the browser dialog box rejects URLs. Even when these flags are set, the browse dialog box displays URLs only if the folder that contains the selected item supports URLs. When the folder's IShellFolder::GetAttributesOf method is called to request the selected item's attributes, the folder must set the SFGAO_FOLDER attribute flag. Otherwise, the browse dialog box will not display the URL.
BIF_USENEWUIUse the new user interface, including an edit box. This flag is equivalent to BIF_EDITBOX | BIF_NEWDIALOGSTYLE.
BIF_UAHINTWhen combined with BIF_NEWDIALOGSTYLE, adds a usage hint to the dialog box, in place of the edit box. BIF_EDITBOX overrides this flag.
BIF_NONEWFOLDERBUTTONDo not include the New Folder button in the browse dialog box.
BIF_NOTRANSLATETARGETSWhen the selected item is a shortcut, return the PIDL of the shortcut itself rather than its target.
BIF_BROWSEFORCOMPUTEROnly return computers. If the user selects anything other than a computer, the OK button is grayed.
BIF_BROWSEFORPRINTEROnly allow the selection of printers. If the user selects anything other than a printer, the OK button is grayed.

In Windows XP and later systems, the best practice is to use a Windows XP-style dialog, setting the root of the dialog to the Printers and Faxes folder (CSIDL_PRINTERS).
BIF_BROWSEINCLUDEFILESThe browse dialog box displays files as well as folders.
BIF_SHAREABLEThe browse dialog box can display shareable resources on remote systems. This is intended for applications that want to expose remote shares on a local system. The BIF_NEWDIALOGSTYLE flag must also be set.
BIF_BROWSEFILEJUNCTIONSWindows 7 and later. Allow folder junctions such as a library or a compressed file with a .zip file name extension to be browsed.
@cPath

A variable by reference into which the selected folder is stored.

cRootPath (optional)

default = NULL

The location of the root folder from which to start browsing. Only the specified folder and its subfolders in the namespace hierarchy appear in the dialog box.
This parameter can be empty or NULL in that case, the namespace root (the Desktop folder) is used.

cCallback (optional)

default = empty

The name of an application-defined function that the dialog box calls when an event occurs.
The function should have the following prototype.

FUNCTION BrowseCallbackProc(hwnd, uMsg, lParam)
ENDFUNC


For a description of the parameters have a look at the BrowseCallbackProc documentation.

Return Value

.T. if a folder was selected, .F. if the dialog was aborted.

See Also

Reference

GetOpenFileName
GetSaveFileName
MessageBoxEx

Used WinApi functions

SHBrowseForFolder
SHILCreateFromPath
SHGetPathFromIDList