Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
General
»
setting the working dir
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Putting a new file on a w...
by
J-G
[
Today
at 04:43:36 pm]
Slow app start on M5 MacB...
by
Thaddy
[
Today
at 04:42:19 pm]
FPC Unleashed (async/awai...
by
440bx
[
Today
at 04:02:43 pm]
Windows 2026_7 update and...
by
Thaddy
[
Today
at 02:41:58 pm]
This week in OPM!
by
wp
[
Today
at 01:59:33 pm]
FastCGI vs. CGI
by
Thaddy
[
Today
at 01:32:45 pm]
Testing Antropic
by
Tomxe
[
Today
at 12:46:14 pm]
GTK3 is now the default w...
by
Thaddy
[
Today
at 10:22:34 am]
authentiacte through goog...
by
Thaddy
[
Today
at 09:12:56 am]
[SOLVED] Stopped compilin...
by
CM630
[
Today
at 08:41:58 am]
[CLOSED] Seeking performa...
by
Xenno
[
Today
at 08:11:26 am]
Lazarus Main not building...
by
Thaddy
[
Today
at 06:31:42 am]
Setting the CURSOR for th...
by
jamie
[
Today
at 02:16:55 am]
TPeriodicTable
by
wp
[
Today
at 12:19:25 am]
I have made some progress...
by
onionmixer
[July 17, 2026, 08:08:34 pm]
How to connect to MariaDb...
by
jcmontherock
[July 17, 2026, 06:23:38 pm]
Accessing VRAM memory wit...
by
LemonParty
[July 17, 2026, 04:45:30 pm]
KOL4 Beta available.
by
Thaddy
[July 17, 2026, 04:45:13 pm]
docking IDE
by
Martin_fr
[July 17, 2026, 02:13:28 pm]
Engineering Software from...
by
jamie
[July 17, 2026, 12:51:57 pm]
[SOLVED] BitBtn Oddity
by
Petrus Vorster
[July 17, 2026, 09:05:55 am]
Difference between @ and ...
by
paule32
[July 17, 2026, 08:18:43 am]
Lazarus Bugfix Release 4....
by
papillon33
[July 17, 2026, 08:15:45 am]
Many recent books on Laza...
by
Khrys
[July 17, 2026, 06:35:48 am]
Isn’t this funny?
by
n7800
[July 16, 2026, 11:57:09 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: setting the working dir (Read 9603 times)
Carver413
Full Member
Posts: 119
setting the working dir
«
on:
February 09, 2011, 01:31:53 am »
I would like my program to use is current dir as a starting place for file operations but when I call GetCurrentDir I get the desktop as the current dir.
Is there a way to set it in lazarus ?
Logged
mas steindorff
Hero Member
Posts: 603
Re: setting the working dir
«
Reply #1 on:
February 09, 2011, 01:48:50 am »
modify the desk top's shortcut "working directory" to be the same as your program
Logged
windows 10 &11, Ubuntu 21+ IDE 3.4 general releases
Carver413
Full Member
Posts: 119
Re: setting the working dir
«
Reply #2 on:
February 09, 2011, 03:52:04 am »
this isn't exactly what I was looking for.In delphi it was possible to retrieve the programs directory from a function (don't remember what that was) but it did not require messing with a shortcut.
Logged
IndianaJones
Hero Member
Posts: 509
Re: setting the working dir
«
Reply #3 on:
February 09, 2011, 04:48:44 am »
I think you are looking for this, ExtractFilePath(Application.ExeName);
Thanks.
Logged
Carver413
Full Member
Posts: 119
Re: setting the working dir
«
Reply #4 on:
February 09, 2011, 04:56:37 am »
Thank you
Logged
marcov
Administrator
Hero Member
Posts: 12950
FPC developer.
Re: setting the working dir
«
Reply #5 on:
February 09, 2011, 04:28:16 pm »
Note that this functionality is not crossplatform.
(or even 100% compatible under windows, it doesn't work when your .exe is in zip folders, compressed with some forms of UPX, on some networkdrives etc)
Logged
Blaazen
Hero Member
Posts: 3241
POKE 54296,15
Re: setting the working dir
«
Reply #6 on:
February 09, 2011, 04:57:08 pm »
Yes, I can confirm that Application.Exename does NOT work after UPX compression on Linux.
Logged
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21
Try Eye-Candy Controls:
https://sourceforge.net/projects/eccontrols/files/
BioHazard
Jr. Member
Posts: 57
Starless...
Re: setting the working dir
«
Reply #7 on:
February 09, 2011, 09:34:55 pm »
This for functions from SysUtils unit might help you:
GetAppConfigDir
GetAppConfigFile
GetCurrentDir
GetUserDir
I use them four and they work on windows and linux.
They all are documented for example below just search function name in function reference:
http://lazarus-ccr.sourceforge.net/docs/rtl/sysutils/index-5.html
As in (still depending on your goal) modern application's data is stored per user - You can use GetAppConfigDir(False) - With False parameter it returns local config dir in users directory, with True global config dir and as in windows 'global config dir' is undefined thing - use it with False.
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
setting the working dir
TinyPortal
© 2005-2018