1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30:
| function TForm1.OpenFolder(root: Integer; Caption: string): string; //Verzeichnis-Öffnen-Dialog-Funktion var bi: TBrowseInfo; lpBuffer: PChar; pidlPrograms, pidlBrowse: PItemIDList; begin if (not SUCCEEDED(SHGetSpecialFolderLocation(GetActiveWindow, root, pidlPrograms))) then exit; lpBuffer := StrAlloc(MAX_PATH); bi.hwndOwner := GetActiveWindow; bi.pidlRoot := pidlPrograms; bi.pszDisplayName := lpBuffer; bi.lpszTitle := PChar(Caption); bi.ulFlags := BIF_RETURNONLYFSDIRS; bi.lpfn := nil; bi.lParam := 0; pidlBrowse := SHBrowseForFolder(bi); if (pidlBrowse <> nil) then if SHGetPathFromIDList(pidlBrowse, lpBuffer) then Result := lpBuffer; StrDispose(lpBuffer); end;
procedure TForm.Button1Click(Sender: TObject); var sDirectory : string; begin sDirectory:= OpenFolder(CSIDL_DRIVES, 'Verzeichnis wählen'); //Übergabe des gewählten Verzeichnisses Showmessage(sDirectory); end; |