VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Folder Browser

FluffyDave  (2 Submissions)   VB function enhancement   Visual Basic 3.0   Advanced   Wed 3rd February 2021

This is a Function which displays the Browse directory dialogue and returns a path as a string. Unlike the usual shell command, this code works even on machines without the Active Desktop or IE 5 installed.

Inputs
lnghWndOwner as Long, the hWnd of the Owner form

Assumes
I think you need IE 4 on the machine, but not 100% sure. Call it like this : strSelectedFolder = BrowseForFolder(me.hwnd)

Returns
BrowseForFolder as String, the path to the selected folder

API Declarations
'API for BrowseForFolder
Private Const BIF_RETURNONLYFSDIRS = 1
Private Const BIF_DONTGOBELOWDOMAIN = 2
Private Const MAX_PATH = 260
Private Declare Function SHBrowseForFolder Lib "shell32" _
(lpbi As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" _
(ByVal pidList As Long, ByVal lpBuffer As String) As Long
Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" _
(ByVal lpString1 As String, ByVal lpString2 As String) As Long
Private Type BrowseInfo
hWndOwner As Long
pIDLRoot As Long
pszDisplayName As Long
lpszTitle As Long
ulFlags As Long
lpfnCallback As Long
lParam As Long
iImage As Long
End Type

Rate Folder Browser (5(5 Vote))
Folder Browser.bas

Folder Browser Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters