DirDialog (Ordner im Dialog auswählen) Verfasst am: 18.06.2009, 12:03
Name: DirDialog Funktion: Öffnet den Ordner Dialog, worin der Benutzer einen Ordner auswählen kann und nicht nur Dateien wie beim CommonDialog. Rückgabe: Ein String (Pfad). Falls leer wurde abgebrochen.
Benötigte Apis: Visual Basic: [code]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[/code][code] 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
If pidl Then path = String(MAX_PATH, 0) SHGetPathFromIDList pidl, path CoTaskMemFree pidl path = Left(path, InStr(path, vbNullChar) - 1) End If DirDialog = path End Function [/code] Verwendung: Visual Basic: [code] Dim sDir As String
sDir = DirDialog("C:") 'Beispiel If LenB(sDir) <> 0 Then 'Euer code End If [/code]