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
Private Const MAX_PATH = 260
Private Const BIF_RETURNONLYFSDIRS = 1
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 Command1_Click()
Dim iNull As Integer, lpIDList As Long
Dim sPath As String, udtBI As BrowseInfo
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
End If
Text1.Text = sPath
End Sub
sPath 是返回的路径
打开工程时,对话框有一个“现存”和一个“最新”的页面选项卡,点“最新”,最近的N个工程都在这里。在文件菜单的下面,也有最近的4个工程。保存就没办法啦,不过有一个投机的办法:新建一个工程,保存好。下次新建工程就直接复制该工程目录,在目录里启动
工程1.vbp进入VB,保存时就不用选目录啦
很简单即可实现,右键单击你使用VB的快捷方式悔纤,选碧灶仿择“属性”,点击“快捷方式”,在“起始位置”文本框中,辩粗输入你想设置的文件夹位置(要带双引号的),比如"E:\MyVB"。欢迎分享,转载请注明来源:内存溢出
评论列表(0条)