| SHGetPathFromIDList, SHBrowseForFolder |
| |
| |
| Prozedur im Modul | |
| 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 |
|
| 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 | |
| |
| Function GetDirectory() As String | |
| Dim bInfo As BROWSEINFO | |
| Dim Path As String | |
| Dim r As Long, x As Long, pos As Integer | |
| bInfo.pidlRoot = 0& | |
| bInfo.lpszTitle = "Wählen Sie bitte einen Ordner aus." | |
| 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 | |
| |
| Private Sub Command1_Click() | Programm mit CommandButton / Formular starten. |
| GetDirectory | |
| End Sub | |
| |