Advertisement
4_2005-2006 Windows API Call/ Explanation #151703

GetFolder

It displays a folder chooser using API. This API call can't be found with the API Viewer.

AI

AI 摘要: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

源代码
original-source
Sub Main()
Dim Folder As String
Folder = GetFolder
If Not Folder = "" Then
  MsgBox Folder
Else
  MsgBox "Couldn't find folder."
End If
End Sub
Function GetFolder(Optional Title As String, Optional hWnd) As String
Dim bi As BROWSEINFO
Dim pidl As Long
Dim Folder As String
Folder = String$(255, Chr$(0))
With bi
  If IsNumeric(hWnd) Then .hOwner = hWnd
  .ulFlags = BIF_RETURNONLYFSDIRS
  .pidlRoot = 0
  If Not IsMissing(Title) Then
    .lpszTitle = Title
  Else
    .lpszTitle = "Select a Folder" & Chr$(0)
  End If
End With
pidl = SHBrowseForFolder(bi)
If SHGetPathFromIDList(ByVal pidl, ByVal Folder) Then
  GetFolder = Left(Folder, InStr(Folder, Chr$(0)) - 1)
Else
  GetFolder = ""
End If
End Function
原始评论 (3)
从 Wayback Machine 恢复