没有合适的资源?快使用搜索试试~ 我知道了~
调用接口弹出选择文件夹的对话框的软件源码
4星 · 超过85%的资源 需积分: 9 36 下载量 185 浏览量
2011-04-10
08:10:40
上传
评论
收藏 2KB TXT 举报
温馨提示
试读
2页
调用接口弹出选择文件夹的对话框本人收集了一些技巧供大家参考,希望斑竹能多放一些时间。按字母或数字顺序排列列表框中的列表项. 将以下代码加入到你的程序中.
资源推荐
资源详情
资源评论
Option Explicit
'====================================================================
'功能:调用接口弹出[选择文件夹]的对话框,返回的是选择路径
'用法:Debug.Print BrowseForFolder(Form1)
'====================================================================
Private Type BrowseInfo
hWndOwner 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
Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Public Function BrowseForFolder(ByRef frmX As VB.Form) As String
Dim iNull As Integer, lpIDList As Long
Dim sPath As String, tBI As BrowseInfo
Const BIF_RETURNONLYFSDIRS As Long = &H1
Const MAX_PATH As Long = 260
With tBI
.hWndOwner = frmX.hWnd
.lpszTitle = "请选择安装路径"
.ulFlags = BIF_RETURNONLYFSDIRS
End With
lpIDList = SHBrowseForFolder(tBI)
If lpIDList Then
'====================================================================
'功能:调用接口弹出[选择文件夹]的对话框,返回的是选择路径
'用法:Debug.Print BrowseForFolder(Form1)
'====================================================================
Private Type BrowseInfo
hWndOwner 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
Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias "SHBrowseForFolderA" (lpBrowseInfo As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Public Function BrowseForFolder(ByRef frmX As VB.Form) As String
Dim iNull As Integer, lpIDList As Long
Dim sPath As String, tBI As BrowseInfo
Const BIF_RETURNONLYFSDIRS As Long = &H1
Const MAX_PATH As Long = 260
With tBI
.hWndOwner = frmX.hWnd
.lpszTitle = "请选择安装路径"
.ulFlags = BIF_RETURNONLYFSDIRS
End With
lpIDList = SHBrowseForFolder(tBI)
If lpIDList Then
资源评论
- tianrui11fit2013-07-24下载下来看了 虽然不是我要的 不过还是学到思路了 谢谢
- lisgang2012-12-09还可以,就是过于简单描述
- ai168_cn2014-09-15很好,正是所需要的
tianya166
- 粉丝: 0
- 资源: 46
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功