Solved

Opendialog Select Directory

Posted on 2002-03-27
2
331 Views
Last Modified: 2010-04-04
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
0
Comment
Question by:skynergy
2 Comments
 
LVL 17

Accepted Solution

by:
inthe earned 50 total points
Comment Utility
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
 

Author Comment

by:skynergy
Comment Utility
Thanx Barry!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now