Option ExplicitPrivate Const BIF_RETURNONLYFSDIRS = 1
Private Const BIF_DONTGOBELOWDOMAIN = 2
Private Const MAX_PATH = 260Private Declare Function SHBrowseForFolder Lib _
"shell32" (lpbi As BrowseInfo) As LongPrivate Declare Function SHGetPathFromIDList Lib _
"shell32" (ByVal pidList As Long, ByVal lpBuffer _
As String) As LongPrivate Declare Function lstrcat Lib "kernel32" _
Alias "lstrcatA" (ByVal lpString1 As String, ByVal _
lpString2 As String) As LongPrivate 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
Private Sub Command1_Click()
'Opens a Browse Folders Dialog Box that displays the
'directories in your computer
Dim lpIDList As Long 'Declare Varibles
Dim sBuffer As String
Dim szTitle As String
Dim tBrowseInfo As BrowseInfoszTitle = "Hello World. Click on a directory and " & _
"it's path will be displayed in a message box"
'Text to appear in the the gray area under the title bar
'telling you what to doWith tBrowseInfo
.hWndOwner = Me.hWnd 'Owner Form
.lpszTitle = lstrcat(szTitle, "")
.ulFlags = BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN
End WithlpIDList = SHBrowseForFolder(tBrowseInfo)If (lpIDList) Then
sBuffer = Space(MAX_PATH)
SHGetPathFromIDList lpIDList, sBuffer
sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)
MsgBox sBuffer
End IfEnd Sub
Private Const BIF_DONTGOBELOWDOMAIN = 2
Private Const MAX_PATH = 260Private Declare Function SHBrowseForFolder Lib _
"shell32" (lpbi As BrowseInfo) As LongPrivate Declare Function SHGetPathFromIDList Lib _
"shell32" (ByVal pidList As Long, ByVal lpBuffer _
As String) As LongPrivate Declare Function lstrcat Lib "kernel32" _
Alias "lstrcatA" (ByVal lpString1 As String, ByVal _
lpString2 As String) As LongPrivate 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
Private Sub Command1_Click()
'Opens a Browse Folders Dialog Box that displays the
'directories in your computer
Dim lpIDList As Long 'Declare Varibles
Dim sBuffer As String
Dim szTitle As String
Dim tBrowseInfo As BrowseInfoszTitle = "Hello World. Click on a directory and " & _
"it's path will be displayed in a message box"
'Text to appear in the the gray area under the title bar
'telling you what to doWith tBrowseInfo
.hWndOwner = Me.hWnd 'Owner Form
.lpszTitle = lstrcat(szTitle, "")
.ulFlags = BIF_RETURNONLYFSDIRS + BIF_DONTGOBELOWDOMAIN
End WithlpIDList = SHBrowseForFolder(tBrowseInfo)If (lpIDList) Then
sBuffer = Space(MAX_PATH)
SHGetPathFromIDList lpIDList, sBuffer
sBuffer = Left(sBuffer, InStr(sBuffer, vbNullChar) - 1)
MsgBox sBuffer
End IfEnd Sub
解决方案 »
- 请问为啥CreateDIBSection后用bitblt截图,但是数据指针所指的位置为0
- 升星帖
- 如何让Excel运行时自动加载csv文件(在线等)
- 这个RC4加密算法貌似有问题啊,不能还原信息,还原后很多字符都变成问号了。有高手可以修改一下吗?
- 过程调用问题
- vb 安装问题 内存不能为
- 高分求购Active report 2.0汉化版本 是设计界面汉化,当然帮助文档汉化了更好
- 当Datagrid中的数据通过其它控件更新后,如何让他刷新自已,显示最新信息 。
- 如何调用控制面板中的[添加/删除程序] ?(望高手指教!)
- 什么地方可以找出IP地址所对应的地区呢?急
- 请问我在打包ActiveX控件时,出现了这样的错误?
- 请问一个很简单的问题?????快来呀!!
还可以使用 Shell 对象.
http://ygyuan.3322.net/
有源代码,可以设置初始目录!