Determining the current directory in UWP apps

In my Delphi application, I determine the current directory by SysUtils.GetCurrentDir function. Of course, when the app is run, the current directory is the folder in which the installer put MyApp.exe file. By default, it is C:\Program Files\MyApp

Everything looks different now, after I packed my program in appx, in order to make a UWP application and submit it to Microsoft Store. Now the app goes to the folder C:\Program Files\WindowsApps\MyApp_1.0.0.0_x86__sp51hrchc9zqj.  However, the function GetCurrentDir returns a different address which is C:\WINDOWS\system32

What can I do about it? I need the address of the folder where the exe file is!
VSmolenskyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Geert GOracle dbaCommented:
did you try paramstr(0) ?
paramstr(0) returns the full file and folder of the exe

you can extract path of it with
ExtractFilePath(ParamStr(0))

Open in new window


current directory is the directory your app is started from, not where it resides
sample:
cd /d c:\windows\system32
start "c:\program files\notepad++\notepad++.exe"

Open in new window


above:
current directory = c:\windows\system32
paramstr(0) = "c:\program files\notepad++\notepad++.exe"

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
VSmolenskyAuthor Commented:
Thank you very much, it works!
1
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.