Opendialog Select Directory

Is there a way to only select a directory without selecting a file using the OpenDialog or some other component? But it should be able to select files as well.

Thanx

Skynergy
skynergyAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
intheConnect With a Mentor Commented:
hi,
yes you can use SHBrowseForFolder() with the ulFlag set to BIF_BROWSEINCLUDEFILES

example:

uses activex,shlobj;

procedure TForm1.Button1Click(Sender: TObject);
var
pi: PItemIDList;
selected : array[0..MAX_PATH] of Char;
bi : TBrowseInfo;
begin
FillChar(bi,SizeOf(bi),#0);
bi.pszDisplayName := @selected[0];
bi.lpszTitle := 'Please Select a Folder';
bi.ulFlags := BIF_BROWSEINCLUDEFILES;
pi := SHBrowseForFolder(bi);
if Assigned(pi) then begin
if SHGetPathFromIDList(pi,selected) then
ShowMessage(selected);
end
else ShowMessage('no selection');
CoTaskMemFree(pi);
end;


Regards Barry
0
 
skynergyAuthor Commented:
Thanx Barry!
0
All Courses

From novice to tech pro — start learning today.