BrowseForFolder - set root directory to Network Domain
I want the BrowseForFolder dialog to start at the domain. I can get it to start at "My Network Places" no problem, but under Windows 2000 you still have to drill thru Entire Network -> Microsoft Windows Network -> MyDomain. I can get the domain name with Environ$("USERDOMAIN"). Is there a way I can get the pidl of that, or set the dialog to start there so the list of computers is immediately presented?
Thanks.
VB Code:
Public Function BrowseForComputer(hwnd As Long) As String
Dim bi As BROWSEINFO
Dim retval As Long
Dim pidl As Long
'get the pidl of "My Network Places"
retval = SHGetSpecialFolderLocation(hwnd, CSIDL_NETWORK, pidl)
If retval <> 0 Then
Debug.Print "Couldn't get network pidl."
BrowseForComputer = ""
Exit Function
End If
With bi
.hwndOwner = hwnd
.pidlRoot = pidl
.pszDisplayName = String$(MAX_PATH, vbNullChar)
.lpszTitle = "Browse for Computer" & vbNullChar
.ulFlags = BIF_BROWSEFORCOMPUTER
End With
retval = SHBrowseForFolder(bi)
If retval <> 0 Then
BrowseForComputer = Replace(bi.pszDisplayName, vbNullChar, "")
Else
BrowseForComputer = ""
End If
Call CoTaskMemFree(pidl)
End Function