Problem with SelectDirectory Function

Posted on 2002-04-16
Last Modified: 2010-04-04
  When the user calls the SelectDirectory function in my app, I want it to default to the root directory (ie. C:\)... but it won't do it. Here's my code:

if SelectDirectory(defdir,[],0) then
else speedbutton21.hint:='';

...the SelectDirectory dialog box always comes up with the directory my app is located in, as its selected directory...weird. There seems to be no way I can force it to go to the root directory.

Any thoughts?

Question by:aztec

Expert Comment

ID: 6946040
You could do it like this:

procedure TForm1.Button1Click(Sender: TObject);
  DefDir : string;
  if SelectDirectory('Please choose a directory:', 'C:\', DefDir) then
    speedbutton21.hint := DefDir
    speedbutton21.hint := '';
LVL 10

Accepted Solution

Jacco earned 50 total points
ID: 6946050
It works if you initialize defdir to "c:\*.*"

Regards Jacco

P.S. It seems to be a small bug in FileCtrl.ProcessPath

Author Comment

ID: 6946067
that gives a complile error:

"Constant object cannot be passed as var parameter"

I don't think it likes the 'Please choose a directory''s expecting a variable.


Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Working with hours 3 58
How to debug For loops? 3 49
Multiple image collision 13 75
How to create virtual printer while installing my application 5 49
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

773 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