

' Requires reference to Microsoft Shell Controls and Automation (SHDOC401.dll or Shell32.dll depending on OS version) Public Function GetSpecialPath(vDir As Variant) As String 'ShellSpecialFolderConstants) As String ' vDir can be either one of the ShellSpecialFolder constants (start with ssf), or a normal path string If Not myFolder Is Nothing Then vbBrowseForFolder = GetSpecialPath(myFolder) '.ParentFolder.ParseName(myFolder.Title).Path RE: Browse Folder Control in vb6? CubeE101 (Programmer) 13 May 04 09:50 If Not myFolder Is Nothing Then vbBrowseForFolder = (myFolder.Title).Path

BrowseForFolder(Form1.hWnd, "Select folder", BIF_Flags, strRoot) Private Function vbBrowseForFolder(Optional strRoot As String, Optional BIF_Flags As BIFS = 0) As String

' or later for most of the Shell32 tricks to work ' SHDOC32 has a reliance on Shell32.dll - this generally needs to be at least version 4.71 'CoInitialize before calling SHBrowseForFolder.īIF_BROWSEFORCOMPUTER = &H1000 'Only returns computers.īIF_BROWSEFORPRINTER = &H2000 'Only returns printers.īIF_BROWSEINCLUDEFILES = &H4000 'Browse for everything 'this flag, you must call OleInitialize or 'delete, and other context menu commands. 'dialog box, reordering, context menus, new folders, 'including: drag and drop capability within the 'this flag provides the user with a larger dialog box As with that you'll need to add a reference to the Microsoft Shell Controls and Automation library (SHDOC401.DLL):īIF_RETURNONLYFSDIRS = &H1 'Only returns file system directoriesīIF_DONTGOBELOWDOMAIN = &H2 'Does not include network folders below domain levelīIF_STATUSTEXT = &H4 'Includes status area in the dialog for use with callbackīIF_RETURNFSANCESTORS = &H8 'Only returns file system ancestors.īIF_EDITBOX = &H10 'allows user to rename selectionīIF_VALIDATE = &H20 'insist on valid editbox result (or CANCEL)īIF_USENEWUI = &H40 'Version 5.0 or later of Shell32.dll. here's a significant revision of my previously posted code on obtaining the paths to the various Windows special folders. Everybody always wants to do this the hard way.
