代码如下,不过我经常看见出现浏览文件夹中还有一个“新建文件夹”的按钮
请问是如何做到的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 TypePrivate Const BIF_RETURNONLYFSDIRS = 1
Private Const MAX_PATH = 260Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" _
(ByVal lpString1 As String, ByVal lpString2 As String) As Long
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 LongPrivate Sub Image6_Click()
Dim iNull As Integer
Dim lpIDList As Long
Dim lResult As Long
Dim spath As String
Dim udtBI As BrowseInfoWith udtBI
.hwndOwner = hwndOwner
.lpszTitle = lstrcat(sPrompt, "")
.ulFlags = BIF_RETURNONLYFSDIRS
End WithlpIDList = SHBrowseForFolder(udtBI)
If lpIDList Then
spath = String$(MAX_PATH, 0)
lResult = SHGetPathFromIDList(lpIDList, spath)
Call CoTaskMemFree(lpIDList)
iNull = InStr(spath, vbNullChar)
If iNull Then
spath = Left$(spath, iNull - 1)
End If
End IfBrowseForFolder = spath
text1.Text = spath
End Sub