天津达内科技:VB只要浏览文件夹,不显示文件夹中的文件,按确定后将返回文件夹的路径

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/30 18:43:06
如上
Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias _
"SHGetPathFromIDListA" (ByVal pIdl As Long, ByVal pszPath As String) As Long

Private Type BrowseInfo
hwndOwner As Long
piDLroot As Long
pszdisplayName As String
lpsztitle As String
ulFlags As Long
lpfncallback As Long
lParam As Long
iImage As Long
End Type

Private Sub Command1_Click()
Dim bi As BrowseInfo
Dim folderid As Long
Dim pb As String
With bi
.hwndOwner = Me.hWnd
.lpsztitle = "把输出的文件存放到这个文件夹:"
.ulFlags = 3
End With
folderid = SHBrowseForFolder(bi)
If folderid = 0 Then Exit Sub
pb = String$(260, 0)
SHGetPathFromIDList folderid, pb
pb = Left$(pb, InStr(pb, vbNullChar) - 1)
Print pb
End Sub

这个可以,只是看不懂,能不能有简单点的