问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

很多程序可以打开“文件夹选项”,自己编程如何实现?

发布网友 发布时间:2022-05-07 08:44

我来回答

1个回答

热心网友 时间:2023-10-22 21:24

'下面的这些你放在模块里
Public 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

Public Const MAX_PATH = 260

Public Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)

Public Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long

Public Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long

Public Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long

Public Function BrowseForFolder(hWndOwner As Long, sPrompt As String) As String

Dim iNull As Integer
Dim lpIDList As Long
Dim lResult As Long
Dim sPath As String
Dim udtBI As BrowseInfo

With udtBI
.hWndOwner = hWndOwner
.lpszTitle = lstrcat(sPrompt, "")
.ulFlags = BIF_RETURNONLYFSDIRS
End With

lpIDList = SHBrowseForFolder(udtBI)

If lpIDList Then
sPath = String$(MAX_PATH, 0)
lResult = SHGetPathFromIDList(lpIDList, sPath)
Call CoTaskMemFree(lpIDList)
iNull = InStr(sPath, vbNullChar)

If iNull Then
sPath = Left$(sPath, iNull - 1)
End If

End If

BrowseForFolder = sPath

End Function

这些你就可以放在过程序:
sdirectoryname = BrowseForFolder(Me.hwnd, "请选择目录")
Text1.Text = sdirectoryname

你要的是不是这样呢。这是我写程序时收集的,具体地址我没有记下来
拿出来和多在一起分享一下。

热心网友 时间:2023-10-22 21:24

'下面的这些你放在模块里
Public 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

Public Const MAX_PATH = 260

Public Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)

Public Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long

Public Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long

Public Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long

Public Function BrowseForFolder(hWndOwner As Long, sPrompt As String) As String

Dim iNull As Integer
Dim lpIDList As Long
Dim lResult As Long
Dim sPath As String
Dim udtBI As BrowseInfo

With udtBI
.hWndOwner = hWndOwner
.lpszTitle = lstrcat(sPrompt, "")
.ulFlags = BIF_RETURNONLYFSDIRS
End With

lpIDList = SHBrowseForFolder(udtBI)

If lpIDList Then
sPath = String$(MAX_PATH, 0)
lResult = SHGetPathFromIDList(lpIDList, sPath)
Call CoTaskMemFree(lpIDList)
iNull = InStr(sPath, vbNullChar)

If iNull Then
sPath = Left$(sPath, iNull - 1)
End If

End If

BrowseForFolder = sPath

End Function

这些你就可以放在过程序:
sdirectoryname = BrowseForFolder(Me.hwnd, "请选择目录")
Text1.Text = sdirectoryname

你要的是不是这样呢。这是我写程序时收集的,具体地址我没有记下来
拿出来和多在一起分享一下。

热心网友 时间:2023-10-22 21:24

'下面的这些你放在模块里
Public 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

Public Const MAX_PATH = 260

Public Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)

Public Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long

Public Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long

Public Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long

Public Function BrowseForFolder(hWndOwner As Long, sPrompt As String) As String

Dim iNull As Integer
Dim lpIDList As Long
Dim lResult As Long
Dim sPath As String
Dim udtBI As BrowseInfo

With udtBI
.hWndOwner = hWndOwner
.lpszTitle = lstrcat(sPrompt, "")
.ulFlags = BIF_RETURNONLYFSDIRS
End With

lpIDList = SHBrowseForFolder(udtBI)

If lpIDList Then
sPath = String$(MAX_PATH, 0)
lResult = SHGetPathFromIDList(lpIDList, sPath)
Call CoTaskMemFree(lpIDList)
iNull = InStr(sPath, vbNullChar)

If iNull Then
sPath = Left$(sPath, iNull - 1)
End If

End If

BrowseForFolder = sPath

End Function

这些你就可以放在过程序:
sdirectoryname = BrowseForFolder(Me.hwnd, "请选择目录")
Text1.Text = sdirectoryname

你要的是不是这样呢。这是我写程序时收集的,具体地址我没有记下来
拿出来和多在一起分享一下。
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
男生买卫生巾支援灾区对吗? 打了耳洞三天下了耳钉,怎么办!! cs七龙珠家里两台电脑怎么连局域网玩 CS七龙珠怎么创建联网房间 CS七龙珠怎样和电脑玩 CS七龙珠能和电脑对打吗 不然怎样调对打模式有哪些地图!!!急需... 糖葫芦的山楂在哪里买 衡水市康宁街与人民路交叉口市一建家属院7号楼,1-201怎么翻译 梦见朋友搬家时小孩因我不愿离去,且小孩坐在床上跑出许老鼠? 梦见搬家是什么预兆解梦 张雨剑虞书欣同框,他们两个还会有更多的合作吗? 推荐一款好闻的香水? 无盘如何安装xp系统!!急 张雨剑花式夸赞虞书欣的原因是什么? U盘制作的启动盘怎么给硬盘分区 LADY GAGA 为什么没有入围和出席2014 MTV录影带大奖呢? 张雨剑花式夸赞虞书欣是怎么回事? 张佑赫用哪款香水 虞书欣张雨剑同框,演过cp的他俩为什么没有传绯闻? nt6 hdd installer提示重启之后没有这个启动项 对lady gaga所有的负面评价 求Lady Gaga的FAME香水广告中一段音频的mp3格式。 Lady Gaga 美妆会成为市场的新宠吗? 花式夸赞虞书欣的张雨剑,为什么认为虞书欣“特红”? 跪求Lady Gaga香水Fame专柜香港具体地址!!!知道的请告知!!不知道的勿回答!!谢谢!!! Lady GaGa 即将面世的香水瓶应该设计成什么样? lady Gaga首款香水国内有卖的嘛?哪里有? 大连有Lady Gaga香水吗 lady gaga fame香水 男生能用么 lady gaga 的香水fame 味道怎样? 吴倩怀孕,张雨剑还在节目上跟虞书欣炒cp,他们的感情究竟如何? 做了一天的 3D3DMAX9 突然死机后就文件就打不开了 根目录下的autoback文件里也没有啦怎么办 非常急啊! 张雨剑对虞书欣红了之后的态度,是不是有明显的转变? 张雨剑承认有女儿,为什么一开始他不承认? 《彗星来的那一夜2》的张雨剑,为什么被说是“人间清醒”? 对于张雨剑所演的剧来说,有你喜欢的角色吗? 苔痕上阶绿的绿字是什么意思(关于词类活用比如形容词 苔痕上阶绿的绿字是什么意思(关于词类活用比如形容 张雨剑承认生女却获全网嘲,多次立单身人设的他要凉了吗? 苔痕上阶绿的绿字是什么意思(关于词类活用比如形容词作动词的) 张雨剑的单身人设翻车了,娱乐圈中还有谁的人设也大翻车了? 指出下列加点词的活用现象并解释 苔痕上阶绿 采访太尴尬,虞书欣多次语出惊人,口无遮拦有多令人讨厌? 虞书欣王耀庆演的是什么电视剧 刘禹锡《陋室铭》中 苔痕上阶绿,草色入帘青 中的“青”和“绿”是使动用法吗?求绿,青两字的赏析! 为什么张雨剑被称为娱乐圈的清流? 苔痕上阶绿,草色的入帘青 张雨剑承认有女儿,你如何看待明星结婚还卖单身人设这种行为? 陋室铭中的文言现象有哪些 一词多义,古今异义,通假字,词类活用 虞书欣也演仙侠剧了,跟王鹤棣搭档超养眼,但两人的感情线为何那么虐心呢?