如何弹出一个选择文件夹路径的对话框选择路径?

原创 2007年09月12日 20:43:00

Private Declare Function SHBrowseForFolder _
        Lib "shell32.dll" Alias "SHBrowseForFolderA" _
        (lpBrowseInfo As BROWSEINFO) As Long
Private Declare Function SHGetPathFromIDList _
        Lib "shell32.dll" _
        (ByVal pidl As Long, _
        pszPath As String) As Long

Private Type BROWSEINFO
    hOwner As Long
    pidlRoot As Long
    pszDisplayName As String
    lpszTitle As String
    ulFlage As Long
    lpfn As Long
    lparam As Long
    iImage As Long
End Type

Public Function ShowDir(MehWnd As Long, _
        DirPath As String, _
        Optional Title As String = "请选择文件夹:", _
        Optional flage As Long = &H1, _
        Optional DirID As Long) As Long
    Dim BI As BROWSEINFO
    Dim TempID As Long
    Dim TempStr As String
   
    TempStr = String$(255, Chr$(0))
    With BI
        .hOwner = MehWnd
        .pidlRoot = 0
        .lpszTitle = Title + Chr$(0)
        .ulFlage = flage
       
    End With
   
    TempID = SHBrowseForFolder(BI)
    DirID = TempID
   
    If SHGetPathFromIDList(ByVal TempID, ByVal TempStr) Then
        DirPath = Left$(TempStr, InStr(TempStr, Chr$(0)) - 1)
        ShowDir = -1
       
    Else
        ShowDir = 0
       
    End If
   
End Function


Private Sub Command1_Click()
ShowDir Me.hWnd, App.Path
End Sub
 

版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

弹出选择文件夹的对话框 BROWSEINFO 的用法【MFC】

以下是在vs2008中编译通过的代码,代码注释详细。要实现的功能是点击“浏览”按钮,即弹出选择文件夹的对话框。并将选择的文件夹或文件路径显示在MessageBox中。 void CMFC_Tro...

CB弹出对话框 选择目录建立文件夹

一、首先弹出对话框建立目录 1.法1 #define NO_WIN32_LEAN_AND_MEAN #include #include // 定义声明如下 bool __fastcall Crn...

弹出文件夹选择对话框

不多说了,直接贴出函数:
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)