| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1781 人关注过本帖
标题:[源码]使用API函数创建”浏览文件夹“对话框
取消只看楼主 加入收藏
griefforyou
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:3336
专家分:0
注 册:2004-4-15
收藏
 问题点数:0 回复次数:0 
[源码]使用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
快速回复:[源码]使用API函数创建”浏览文件夹“对话框
数据加载中...
 
   



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

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