1 Option Explicit
2
3 Private Type BROWSEINFO
4 hOwner As Long
5 pidlRoot As Long
6 pszDisplayName As String
7 lpszTitle As String
8 ulFlags As Long
9 lpfn As Long
10 lParam As Long
11 iImage As Long
12 End Type
13
14 Private Const BIF_RETURNONLYFSDIRS = &H1 '浏览文件夹
15 Private Const BIF_NEWDIALOGSTYLE = &H40 '新样式(有新建文件夹按钮,可调整对话框大小)
16 Private Const BIF_NONEWFOLDERBUTTON = &H200 '新样式中,没有新建按钮(只调大小)
17
18 Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" _
19 (ByVal pidl As Long, _
20 ByVal pszPath As String) As Long
21 Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" _
22 (lpBrowseInfo As BROWSEINFO) As Long
23
24 Public Function GetFolderName(hWnd As Long, Text As String) As String
25 Dim bi As BROWSEINFO
26 Dim pidl As Long
27 Dim path As String
28 With bi
29 .hOwner = hWnd
30 .pidlRoot = 0& '根目录,一般不需要改
31 .lpszTitle = Text
32 .ulFlags = BIF_RETURNONLYFSDIRS '根据需要调整
33 End With
34 pidl = SHBrowseForFolder(bi)
35 path = Space$(512)
36 If SHGetPathFromIDList(ByVal pidl, ByVal path) Then
37 GetFolderName = Left(path, InStr(path, Chr(0)) - 1)
38 End If
39 End Function
正文
[VB]用API打开浏览文件夹对话框,选择文件夹2012-12-12 12:37:00
【评论】 【打印】 【字体:大 中 小】 本文链接:http://blog.pfan.cn/enc999/53980.html
阅读(3396) | 评论(0)
版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!
评论