http://www.mvps.org/vbnet/code/browse/browseadv.htm
解决方案 »
- 定义recordset时要new吗?
- 想用kodak图像控件ImgEdit.ocx做可鼠标拖动或鼠标滚轮缩放图像的浏览器
- 在command1 的控件数组中为什么总是提缺标示符
- 如何在VB中截取SYBASE ASA的日志
- 移动何联通能够通信,他们之间是怎么连接的呀?是不是哪里有个公共的接口?
- 請問:用Vb訪問Access數據庫,用ADO好還是用DAO好?為什么?謝謝!
- ACTIVEX 在ASP中应用的问题,急!!
- winxp的MDAC版本问题!
- 制作安装软件的问题 ,谁解决,我放1000分
- winsock如何判断客户机已经非正常退出如:死机,掉电,网线拔掉等
- 对较多的记录修改后(在msflexgrid上),如何快速有效地进行保存?(Access数据库)
- 错误请教
http://www.applevb.com/sourcecode/2054_EBrowseF.zip
SHBrowseForFolder函数大家可能用过,这个代码展示了一个扩充用法,可以让你在Dialog中选择的时候就显示选择了那个目录。
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 Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
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 Sub Form_Load()
Dim iNull As Integer, lpIDList As Long, lResult As Long
Dim sPath As String, udtBI As BrowseInfo With udtBI
'Set the owner window
.hWndOwner = Me.hWnd
'lstrcat appends the two strings and returns the memory address
.lpszTitle = lstrcat("C:\", "")
'Return only if the user selected a directory
.ulFlags = BIF_RETURNONLYFSDIRS
End With 'Show the 'Browse for folder' dialog
lpIDList = SHBrowseForFolder(udtBI)
If lpIDList Then
sPath = String$(MAX_PATH, 0)
'Get the path from the IDList
SHGetPathFromIDList lpIDList, sPath
'free the block of memory
CoTaskMemFree lpIDList
iNull = InStr(sPath, vbNullChar)
If iNull Then
sPath = Left$(sPath, iNull - 1)
End If
End If MsgBox sPath
End Sub