Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
General
»
[Solved] GetCurrentDir is giving me location of my shortcut
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
Lazarus Bugfix Release 4...
by
Martin_fr
[
Today
at 08:24:51 pm]
[SOLVED] Heaptrc reports ...
by
Bart
[
Today
at 07:06:57 pm]
Anyone interested in help...
by
ad1mt
[
Today
at 05:28:08 pm]
Lazarus Blowfish
by
rvk
[
Today
at 05:17:17 pm]
AArch64. Slow program sta...
by
LemonParty
[
Today
at 04:46:31 pm]
Help with search and repa...
by
avk
[
Today
at 04:35:29 pm]
An Idea for a helpful uti...
by
Curt Carpenter
[
Today
at 04:33:20 pm]
Info for PTCGraph users.....
by
Handoko
[
Today
at 04:01:45 pm]
Initialize list in functi...
by
PeterHu
[
Today
at 10:33:27 am]
Tips for cross-compiling ...
by
Seenkao
[
Today
at 09:25:29 am]
Drawing a picture on the ...
by
DMH
[
Today
at 05:01:07 am]
How detect a keypress in ...
by
Remy Lebeau
[November 09, 2025, 07:49:50 pm]
Paradox date filter
by
tawfiq-lz
[November 09, 2025, 07:46:20 pm]
Why is there no Chinese s...
by
Ten_Mile_Hike
[November 09, 2025, 06:55:11 pm]
Convert table to JSON arr...
by
paweld
[November 09, 2025, 05:56:56 pm]
Unexpected lack of error ...
by
n7800
[November 09, 2025, 05:39:10 pm]
FPC 3.2.4-rc1 available
by
pleumann
[November 09, 2025, 05:12:32 pm]
application crashes on st...
by
Thaddy
[November 09, 2025, 04:17:28 pm]
Blog area?
by
Martin_fr
[November 09, 2025, 02:00:17 pm]
SimpleXML
by
ednaldomoreira
[November 09, 2025, 01:45:18 pm]
What happens if you use "...
by
Thaddy
[November 09, 2025, 01:39:12 pm]
CustomDraw package compil...
by
lainz
[November 09, 2025, 01:21:58 pm]
Register global hotkey
by
Thaddy
[November 09, 2025, 12:46:46 pm]
How to port TArray.Sort?
by
Thaddy
[November 09, 2025, 12:20:36 pm]
Dynamic libraries in Linu...
by
Fred vS
[November 08, 2025, 10:28:42 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: [Solved] GetCurrentDir is giving me location of my shortcut (Read 602 times)
nikel
Sr. Member
Posts: 257
[Solved] GetCurrentDir is giving me location of my shortcut
«
on:
February 10, 2025, 06:04:18 am »
Hello, I'm trying to get my executeble's location. I had been using
GetCurrentDir
command, I compiled it as msi and installed it. The desktop shortcut is giving me this folder:
C:\Users\User\Desktop
How can I get location of my executable?
«
Last Edit: February 10, 2025, 09:10:21 am by nikel
»
Logged
Fibonacci
Hero Member
Posts: 788
Internal Error Hunter
Re: GetCurrentDir is giving me location of my shortcut
«
Reply #1 on:
February 10, 2025, 06:29:25 am »
GetCurrentDir returns current working directory. For the actual location you can use ParamStr(0):
Code: Pascal
[Select]
[+]
[-]
ExtractFileDir
(
ParamStr
(
0
)
)
If on Windows, you can also use GetModuleFileName:
Code: Pascal
[Select]
[+]
[-]
var
s
:
string
;
begin
setlength
(
s
,
500
)
;
setlength
(
s
,
GetModuleFileName
(
0
,
@
s
[
1
]
,
length
(
s
)
)
)
;
writeln
(
'GetModuleFileName = '
,
ExtractFileDir
(
s
)
)
;
Logged
nikel
Sr. Member
Posts: 257
Re: GetCurrentDir is giving me location of my shortcut
«
Reply #2 on:
February 10, 2025, 07:43:24 am »
Thanks for the info. I'll try that.
Logged
Zvoni
Hero Member
Posts: 3135
Re: GetCurrentDir is giving me location of my shortcut
«
Reply #3 on:
February 10, 2025, 08:35:52 am »
Application.Location?
Logged
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
[Solved] GetCurrentDir is giving me location of my shortcut
TinyPortal
© 2005-2018