Tools Links Login

Dialog - folder - using APi

The following is reprinted for archival purposes from Gary Beene's Information Center, with permission from Mr. Beene himself.


Private 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

Private Const BIF_RETURNONLYFSDIRS = &H1
Private Const BIF_DONTGOBELOWDOMAIN = &H2
Private Const BIF_STATUSTEXT = &H4
Private Const BIF_RETURNFSANCESTORS = &H8
Private Const BIF_BROWSEFORCOMPUTER = &H1000
Private Const BIF_BROWSEFORPRINTER = &H2000
Private Const MAX_PATH = 260

Private Declare Function SHGetPathFromIDList Lib "shell32" _
   Alias "SHGetPathFromIDListA" _
( ByVal pidl As Long , _
   ByVal pszPath As String ) As Long

Private Declare Function SHBrowseForFolder Lib "shell32" _
   Alias "SHBrowseForFolderA" _
(lpBrowseInfo As BROWSEINFO) As Long

Private Declare Sub CoTaskMemFree Lib "ole32" _
  ( ByVal pv As Long )


Private Sub  SelectFolder()
  Dim bi As BROWSEINFO
  Dim pidl As Long
  Dim path As String
  Dim pos As Long
  With bi
   .hOwner = Me .hwnd
   .pidlRoot = 0&
   .lpszTitle = "Select image folder"
   .ulFlags = BIF_RETURNONLYFSDIRS
  End With
pidl = SHBrowseForFolder(bi)
path = Space$(MAX_PATH)
  If SHGetPathFromIDList( ByVal pidl, ByVal path) Then
    pos = InStr(path, Chr $(0))
    txtFolder.Text = Lcase $(Left(path, pos - 1))
  End If
   Call CoTaskMemFree(pidl)
End Sub

About this post

Posted: 2021-02-11
By: ArchiveBot
Viewed: 211 times

Categories

Visual Basic 6

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.