不用了 用API (SHBrowseForFolder函数) 就搞定了啊
给你代码
一个按钮 cmdViewFolder 一个文本框 txtPath
[CODE]
Option Explicit
Private Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Const BIF_RETURNONLYFSDIRS = &H1
Private Pidl As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal Pidl As Long, ByVal pszPath As String) As Long
Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Private Sub cmdViewFolder_Click()
Dim BI As BROWSEINFO
Dim lRtn As Long
Dim lPidl As Long
Dim sFPath As String
Dim iPos As Integer
'句柄
BI.hOwner = Me.hWnd
'展开根目录
BI.pidlRoot = 0&
'列表框标题
BI.lpszTitle = "请选择软件安装路径:"
'规定只能选择文件夹,其他无效
BI.ulFlags = BIF_RETURNONLYFSDIRS
'调用API函数显示列表框
lPidl = SHBrowseForFolder(BI)
'利用API函数获取返回的路径
sFPath = Space$(512)
lRtn = SHGetPathFromIDList(ByVal lPidl&, ByVal sFPath)
If lRtn Then
iPos = InStr(sFPath, Chr$(0))
txtPath.Text = Left(sFPath, iPos - 1)
Else
txtPath.Text = ""
End If
End Sub
[/CODE]
世界上有两种人:懂二进制的和不懂二进制的。