AW: Art Explorerfenster zum Pfad auswählen erzeugen
04.08.2006 10:27:14
Heiko
Hallo Atikar,
ich glaube du meinst wohl eher sowas: Alles in ein Allgemeines Modul.
Option Explicit
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
Private Declare Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Private Declare Sub CoTaskMemFree Lib "ole32" (ByVal hMem As Long)
Private 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
Function Pfad_auswählen(strText As String) As String
Dim bInfo As BROWSEINFO
Dim strPath As String
Dim lngret As Long
Dim intpos As Integer
With bInfo
' Einen Default Pfad einzurichten gestaltet sich nicht so einfach, dafür sind weitere
' API Aufrufe notwendig und deswegen hier erstmal nicht weiter verfolgt. So 13.03.05
.pidlRoot = 0&
.lpszTitle = strText
.ulFlags = &H1
End With
lngret = SHBrowseForFolder(bInfo)
strPath = Space$(512)
lngret = SHGetPathFromIDList(ByVal lngret, ByVal strPath)
If lngret Then
intpos = InStr(strPath, Chr$(0))
Pfad_auswählen = Left(strPath, intpos - 1)
Else
Pfad_auswählen = vbNullString
End If
' Speicher wieder frei machen.
CoTaskMemFree lngret
End Function
Sub Testen()
MsgBox Pfad_auswählen("Bitte wählen Sie einen Pfad")
End Sub
Gruß Heiko
PS: Rückmeldung wäre nett !