Folder browser - restricting root folder - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Folder browser - restricting root folder

arjunsubarjunsub Posts: 32Member

I'm trying to restrict the root folder in the folder browser using windows api. I somehow need to obtain a folder's CSIDL or PIDL in order to restrict it (using the pidlroot setting). I'd be really grateful if somebody can suggest a solution.

Here is the function I have right now :

Public Function BrowseFolder() As String

Dim bi As BrowseInfo
Dim pidl As Long
Dim path As String
Dim Pos As Integer

BrowseFolder = ""

bi.lpszTitle = "Please select a Folder"
bi.ulFlags = &H1
pidl = SHBrowseForFolder(bi)
path = Space$(MAX_PATH)

If SHGetPathFromIDList(ByVal pidl, ByVal path) Then
Pos = InStr(path, Chr$(0))
BrowseFolder = Left(path, Pos - 1)
End If

If (Right$(BrowseFolder, 1) <> "" And BrowseFolder <> "") Then
BrowseFolder = BrowseFolder & ""
End If

Call CoTaskMemFree(pidl)

End Function

Thanks a lot!
Sign In or Register to comment.