标题:[源码]使用API函数创建”浏览文件夹“对话框
只看楼主
griefforyou
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:3336
专家分:0
注 册:2004-4-15
 问题点数:0 回复次数:3 
[源码]使用API函数创建”浏览文件夹“对话框

Option Explicit

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 Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem 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

Const BIF_RETURNONLYFSDIRS = 1 Const MAX_PATH = 260

Private Sub Command1_Click() Dim SearchPath As String Dim sPath As String, udtBI As BrowseInfo Dim lpIDList As Long, iNull As Long With udtBI '设置浏览窗口 .hWndOwner = Me.hWnd '返回选中的目录 .ulFlags = BIF_RETURNONLYFSDIRS End With '调出浏览窗口 lpIDList = SHBrowseForFolder(udtBI) If lpIDList Then sPath = String$(MAX_PATH, 0) '获取路径 SHGetPathFromIDList lpIDList, sPath '释放内存 CoTaskMemFree lpIDList iNull = InStr(sPath, vbNullChar) If iNull Then sPath = Left$(sPath, iNull - 1) End If MsgBox "你选择的目录是" & sPath End If End Sub

搜索更多相关主题的帖子: API 对话框 源码 函数 文件 
2004-05-11 16:39
chuting
Rank: 1
等 级:新手上路
帖 子:9
专家分:0
注 册:2004-5-18
得分:0 
高手
2004-05-18 09:18
icebean
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2004-5-25
得分:0 
不错

天天学到一点
2004-06-08 07:42
yuyuer
Rank: 1
等 级:新手上路
帖 子:19
专家分:0
注 册:2008-9-26
得分:0 
不错
2008-11-23 20:25



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-1337-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.110426 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved