Как открыть стандартное диалоговое окно выбора папки?

Вопрос:

Как открыть стандартное диалоговое окно выбора папки?

Ответ:

Public Type BROWSEINFO
    hOwner As Long
    pidlRoot As Long
    pszDisplayName As String
    lpszTitle As String
    ulFlags As Long
    lpfn As Long
    lParam As Long
    iImage As Long
End Type

Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias
"SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As
Long
Declare Function SHBrowseForFolder Lib "shell32.dll" Alias
"SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Public Const BIF_RETURNONLYFSDIRS = &H1

Public Function SelectDir() As String
Dim myBrowseInfo As BROWSEINFO
Dim execNumderDir As Boolean
Dim NumderDir As Long
Dim pos As Integer
Dim myPath_512 As String
With myBrowseInfo
    .hOwner = Form1.hWnd
    .pidlRoot = 0&
    .lpszTitle = "Выберите директорию"
    .ulFlags = BIF_RETURNONLYFSDIRS
End With
NumderDir& = SHBrowseForFolder(myBrowseInfo)
myPath_512$ = Space$(512)
execNumderDir = SHGetPathFromIDList(ByVal NumderDir&, ByVal
myPath_512$)
If execNumderDir Then
    pos = InStr(myPath_512$, Chr$(0))
    MyPath = Left(myPath_512$, pos - 1)
Else: MyPath = Empty
End If
SelectDir = MyPath
End Function

    DedMorozzz