Results 1 to 3 of 3

Thread: BrowseForFolder - set root directory to Network Domain

  1. #1

    Thread Starter
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032

    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:
    1. Public Function BrowseForComputer(hwnd As Long) As String
    2.     Dim bi As BROWSEINFO
    3.     Dim retval As Long
    4.     Dim pidl As Long
    5.    
    6.     'get the pidl of "My Network Places"
    7.     retval = SHGetSpecialFolderLocation(hwnd, CSIDL_NETWORK, pidl)
    8.    
    9.     If retval <> 0 Then
    10.         Debug.Print "Couldn't get network pidl."
    11.         BrowseForComputer = ""
    12.         Exit Function
    13.     End If
    14.    
    15.     With bi
    16.         .hwndOwner = hwnd
    17.         .pidlRoot = pidl
    18.         .pszDisplayName = String$(MAX_PATH, vbNullChar)
    19.         .lpszTitle = "Browse for Computer" & vbNullChar
    20.         .ulFlags = BIF_BROWSEFORCOMPUTER
    21.     End With
    22.    
    23.     retval = SHBrowseForFolder(bi)
    24.    
    25.     If retval <> 0 Then
    26.         BrowseForComputer = Replace(bi.pszDisplayName, vbNullChar, "")
    27.     Else
    28.         BrowseForComputer = ""
    29.     End If
    30.    
    31.     Call CoTaskMemFree(pidl)
    32.  
    33. End Function
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

  2. #2
    jim mcnamara
    Guest
    .pidl = CSIDL_NETHOOD gets you a little closer.

    I think it may be closer to what you want. There is no CSIDL_NODENAME or CSIDL_MYDOMAIN constant, which is what you would have to have to start with a domain server-centric view of a domain.

    I don't know anything that will actually help. MSDNdoesn't have anything I can find either. Interesting question....

  3. #3

    Thread Starter
    Black Cat JoshT's Avatar
    Join Date
    Nov 2000
    Location
    WNY, USA
    Posts
    4,032
    No, the CSIDL_NETWORK constant works better. Thanks anyway.

    I would think you could set it to an arbitrary folder...
    Josh
    Get these: Mozilla Opera OpenBSD
    I have books for sale: "MCSD in a Nutshell" and "VB Distributed Exam Cram" - PM me for details. Will also trade for a decent ATX Pentium 2 MB/CPU/RAM combo.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width