Advertisement
1_2002 Files/ File Controls/ Input/ Output #104024

Win95DirectoryPrompt

Prompting the User for a Directory in Win95. Windows' common dialogs are great if you want the user to select a file, but what if you want them to select a directory? Call the following function, which relies on Win32's new SHBrowseForFolder function:

AI

AI Summary: 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.

Source Code
original-source
Public Function BrowseForFolder(hWndOwner As Long, sPrompt As String) As String
  Dim iNull As Integer
  Dim lpIDList As Long
  Dim lResult As Long
  Dim sPath As String
  Dim udtBI As BrowseInfo
  With udtBI
    .hWndOwner = hWndOwner
    .lpszTitle = lstrcat(sPrompt, "")
    .ulFlags = BIF_RETURNONLYFSDIRS
  End With
  lpIDList = SHBrowseForFolder(udtBI)
  If lpIDList Then
    sPath = String$(MAX_PATH, 0)
    lResult = SHGetPathFromIDList(lpIDList, sPath)
    Call CoTaskMemFree(lpIDList)
    iNull = InStr(sPath, vbNullChar)
    If iNull Then
      sPath = Left$(sPath, iNull - 1)
    End If
  End If
  BrowseForFolder = sPath
End Function
Original Comments (3)
Recovered from Wayback Machine