Jump to content
Ian Branch

ExtractFilePath v TDirectory.GetCurrentDirectory

Recommended Posts

Hi Team,

In a simple Win32 App, when might ExtractFilePath(Application.ExeName) not be the same as TDirectory.GetCurrentDirectory if called in the Main Form??

 

Regards & TIA,

Ian

Share this post


Link to post

The program was started with a different current folder option, or the WIN API SetCurrentDirectory was called somewhere from the application.

Share this post


Link to post

Hi...:classic_cool:

https://docwiki.embarcadero.com/Libraries/Seattle/en/System.IOUtils.TDirectory.GetCurrentDirectory

Quote

Returns the current working directory.

Use GetCurrentDirectory to get the current directory

Current working directory:  99% <> ExtractFilePath(Application.ExeName) 

Quote

or the WIN API SetCurrentDirectory was called somewhere

Example: Current working directory can be "C:\Windows\System32" or else a special folder...

 

Share this post


Link to post
2 hours ago, Ian Branch said:

Tks Lajos,

Neither apply in my situation.

 

Ian

This can only be true if you are the only person ever to run your program.

 

These two things, the directory containing the executable and the working directory are completely different and unrelated things. Generally you don't want to use the working directory in a GUI program. It's really only useful in a console app where you can think of the working directory as one of the inputs to the process.

 

What problem are you actually trying to solve?

Share this post


Link to post

My experience it is one of these:

command line is different dir than exe

image.thumb.png.c9345bdc0854791e26007f0ac06d9a68.png

 

Short cut start in:

image.thumb.png.2beff941e02d78289b077655e2190e68.png

Share this post


Link to post

Hi Guys,

Thank you for your inputs.

I wasn't trying to solve any particular problem, just curious.

 

Ian

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×