Pfadauswahl mit Baum und Default Pfad
14.04.2005 15:38:36
marko_ti
ich benutze die Funktion (s.u.), um einen Pfad auswählen zu lassen (Pfad = GetDirectory). Problem: ich muss immer bei der Wurzel (alle Laufwerke + Netzlaufwerke) starten - wie kann ich den Baum bei Aufruf auf einen Default Pfad setzen?
Ich weiß, bei PfadPlusFile = Application.GetOpenFilename() geht es per vorgeschaltetem ChDir "c:\DefaultPfad", aber dort muss ich auch ein File wählen - und das will ich nicht.
Danke für Eure Tips!
Gruß Marko
Public Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Declare
Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Declare
Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Function GetDirectory(Optional Msg As String) As String
Dim bInfo As BROWSEINFO
Dim Path As String
Dim r As Long, x As Long, pos As Integer
bInfo.pidlRoot = 0&
If IsMissing(Msg) Then
bInfo.lpszTitle = "Wählen Sie bitte einen Ordner aus."
Else
bInfo.lpszTitle = Msg
End If
bInfo.ulFlags = &H1
x = SHBrowseForFolder(bInfo)
Path = Space$(512)
r = SHGetPathFromIDList(ByVal x, ByVal Path)
If r Then
pos = InStr(Path, Chr$(0))
GetDirectory = Left(Path, pos - 1)
Else
GetDirectory = ""
End If
End Function