winapivb6shell32.dll

Shell BrowseForFolder preselected path


I have this call:

oShell.BrowseForFolder(Me.hwnd, "Select path:", 0, "C:\dir\")

This opens a standard file browser dialog with "C:\dir\" as root. My problem is that you can not browse above the root folder. (as specified in doc http://msdn.microsoft.com/en-us/library/bb774065(v=vs.85).aspx)

Any suggestions on oppening this dialog with a selected path and full browsing posibility?

Thanks


Solution

  • The way to do this involves calling the underlying API, SHBrowseForFolder().

    Since you want the entire shell namespace to be available you need to pass NULL as pidlRoot. In order to select your desired folder you will need to provide a callback in lpfn. Make this callback respond to BFFM_INITIALIZED by setting the selected folder. This selection is performed by sending the BFFM_SETSELECTION message to the dialog's window handle (passed to the callback function).

    No code because I don't have VB6, but hopefully this outline of the method is enough to get you on your way.