Drive List with Mapped Network Drives and My Network Places

How do I get the Drive List Box to show all the 'common' things that show up in other applictations, such as My Documents, Desktop, and more importantly Mapped Network Drives and My Network Places?
tristan256Asked:
Who is Participating?
 
CimperialiConnect With a Mentor Commented:
if you want it to look similar to the explorer, you have to use an imagecombo and load items in it using filesystemoBject to detect the drives and the special folders.
A really easier one is to use the ShBrowseForFoler Api:
From api-guide (a free tool you can download at http://www.allapi.net)

Requires Windows NT 4.0 or later; Requires Windows 95 or later
Private Type BrowseInfo
    hWndOwner As Long
    pIDLRoot As Long
    pszDisplayName As Long
    lpszTitle As Long
    ulFlags As Long
    lpfnCallback As Long
    lParam As Long
    iImage As Long
End Type
Const BIF_RETURNONLYFSDIRS = 1
Const MAX_PATH = 260
Private Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long)
Private Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long
Private Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long
Private Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long
Private Sub Form_Load()
    'KPD-Team 1998
    'URL: http://www.allapi.net/
    'KPDTeam@Allapi.net
    Dim iNull As Integer, lpIDList As Long, lResult As Long
    Dim sPath As String, udtBI As BrowseInfo

    With udtBI
        'Set the owner window
        .hWndOwner = Me.hWnd
        'lstrcat appends the two strings and returns the memory address
        .lpszTitle = lstrcat("Choose a Folder", "")
        'Return only if the user selected a directory
        .ulFlags = BIF_RETURNONLYFSDIRS
    End With

    'Show the 'Browse for folder' dialog
    lpIDList = SHBrowseForFolder(udtBI)
    If lpIDList Then
        sPath = String$(MAX_PATH, 0)
        'Get the path from the IDList
        SHGetPathFromIDList lpIDList, sPath
        'free the block of memory
        CoTaskMemFree lpIDList
        iNull = InStr(sPath, vbNullChar)
        If iNull Then
            sPath = Left$(sPath, iNull - 1)
        End If
    End If

    MsgBox sPath
End Sub
0
 
GrahamSkanRetiredCommented:
You might find the common dialog control a bit easier.

I use this function in a form with the control on it.

Public Function FileBrowse(Message As String, Expectedpath As String, DefaultName As String, FilePattern As String, Save As Boolean) As String
Dim NewFileName As String
    On Error GoTo FileBrowseError
    Me.CommonDialog1.CancelError = True
    Me.CommonDialog1.FileName = DefaultName
    Me.CommonDialog1.InitDir = Expectedpath
    Me.CommonDialog1.DialogTitle = App.Title & " - " & Message
    Me.CommonDialog1.FilterIndex = 1
    Me.CommonDialog1.Filter = FilePattern
    If Save Then
        Me.CommonDialog1.Flags = 0 Or cdlOFNHideReadOnly
        Me.CommonDialog1.ShowOpen
    Else
        Me.CommonDialog1.Flags = 0 Or cdlOFNFileMustExist Or cdlOFNHideReadOnly Or cdlOFNReadOnly
        Me.CommonDialog1.ShowOpen
    End If
    FileBrowse = Me.CommonDialog1.FileName
FileBrowseError:
    Exit Function
End Function

0
 
CleanupPingCommented:
Hi tristan256,
This old question (QID 20560666) needs to be finalized -- accept an answer, split points, or get a refund.  Please see http://www.cityofangels.com/Experts/Closing.htm for information and options.
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
SethiCommented:
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
[Accept Cimperiali's comment as Answer]
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

[Sethi]
EE Cleanup Volunteer
0
 
CimperialiCommented:
Let me suggest to split points with GrahamSkan, as also his answer is a solution that can work.
Cesare Imperiali
0
 
GrahamSkanRetiredCommented:
Thank you Cesare. If I were cleaning up, I'd have made the same recommendation that Sethi did. You were the first to give a viable solution, and there are only 50 points to split. But it's nice to be recognised
Graham
0
 
CimperialiCommented:
;-)
Have a nice day, Graham

Cesare
0
All Courses

From novice to tech pro — start learning today.