Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-08

Path that .exe file is running from

14 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Reinier Olislagers
to Richard Mace
Richard Mace wrote
Hi, How can I get the path of where my application is running from? I have tried Application.Name but "Application" is not found?

e.g. paramstr(0)

Note: getting the exe path is not guaranteed to work on all platforms (e.g. OSX). Please see the documentation as well as the multiplatform programming articles on the wiki.

Reply by email

Richard Mace
to Reinier Olislagers
Reinier Olislagers wrote 11 lines
On 01/08/2013 20:56, Richard Mace wrote: > Hi, > How can I get the path of where my application is running from? > I have tried Application.Name but "Application" is not found? > e.g. paramstr(0) Note: getting the exe path is not guaranteed to work on all platforms (e.g. OSX). Please see the documentation as well as the multiplatform programming articles on the wiki.

Perfect, thanks Reinier

Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130801/fc34500e/attachment.html>

Reply by email

Michael Schnell
to Richard Mace: How can I get the path of where my application is running from? I have tried…
Richard Mace wrote
How can I get the path of where my application is running from? I have tried Application.Name

Application.ExeName

but "Application" is not found?

"Application" is only available when using appropriate "WidgetTypes". Not when doing simple command line tools.

-Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20130802/84b288f3/attachment.html>

Reply by email

Michael Van Canneyt
to Michael Schnell
Michael Schnell wrote 10 lines
On 08/01/2013 08:56 PM, Richard Mace wrote: How can I get the path of where my application is running from? I have tried Application.Name Application.ExeName but "Application" is not found? "Application" is only available when using appropriate "WidgetTypes". Not when doing simple command line tools.

It is if you use TCustomApplication from custapp.

Michael.

Reply by email

Michael Schnell
to Michael Van Canneyt
Michael Van Canneyt wrote 5 lines
On Fri, 2 Aug 2013, Michael Schnell wrote: > On 08/01/2013 08:56 PM, Richard Mace wrote: > "Application" is only available when using appropriate "WidgetTypes". > Not when doing simple command line tools. It is if you use TCustomApplication from custapp.

This _is_ a (on that behalf) " appropriate WidgetType" (for a "non-GUI Application") :-)

-Michael

Reply by email

Michael Van Canneyt
to Michael Schnell
Michael Schnell wrote 8 lines
On 08/02/2013 10:32 AM, Michael Van Canneyt wrote: > On Fri, 2 Aug 2013, Michael Schnell wrote: >> On 08/01/2013 08:56 PM, Richard Mace wrote: >> "Application" is only available when using appropriate "WidgetTypes". Not >> when doing simple command line tools. > It is if you use TCustomApplication from custapp. This _is_ a (on that behalf) " appropriate WidgetType" (for a "non-GUI Application") :-)

No. CustomApplication is not a widget type.

Widget types do not even enter the picture, customapplication is included in FPC, not Lazarus.

Michael.

Reply by email

Henry Vermaak
to Michael Schnell: This _is_ a (on that behalf) " appropriate WidgetType" (for a "non-GUI Application") :-)…
Michael Schnell wrote 8 lines
On 08/02/2013 10:32 AM, Michael Van Canneyt wrote: >On Fri, 2 Aug 2013, Michael Schnell wrote: >>On 08/01/2013 08:56 PM, Richard Mace wrote: >>"Application" is only available when using appropriate >>"WidgetTypes". Not when doing simple command line tools. >It is if you use TCustomApplication from custapp. This _is_ a (on that behalf) " appropriate WidgetType" (for a "non-GUI Application") :-)

It's not a widget type, it's just a class. I use it in all my command line programs, big or small.

Henry

Reply by email

Michael Schnell
to Michael Van Canneyt: No. CustomApplication is not a widget type. Widget types do not even enter the picture,…
Michael Van Canneyt wrote
Widget types do not even enter the picture, customapplication is included in FPC, not Lazarus.

I see. Thanks.

So you suggest deriving and instantiating a propriety application from the TCustomApplication class ?

Will that automatically provide the correct string as MyApplication.ExeName ?

I thing just using the Lazarus NoGUI Widget Type is more appropriate.

-Michael

Reply by email

Michael Van Canneyt
to Michael Schnell
Michael Schnell wrote 9 lines
On 08/02/2013 11:07 AM, Michael Van Canneyt wrote: > Widget types do not even enter the picture, customapplication is included > in FPC, not Lazarus. > I see. Thanks. So you suggest deriving and instantiating a propriety application from the TCustomApplication class ?

I don't suggest anything. I just react on incorrect information.

Will that automatically provide the correct string as MyApplication.ExeName ?

Yes.

I thing just using the Lazarus NoGUI Widget Type is more appropriate.

No, for 2 reasons:

1) It creates unwanted dependencies.
2) It creates the illusion of functionality which isn't actually there.

Sooner or later it will bite you in the leg.

Michael.

Reply by email

Michael Schnell
to Michael Van Canneyt
Michael Van Canneyt wrote
> So you suggest deriving and instantiating a propriety application > from the TCustomApplication class ? I don't suggest anything. I just react on incorrect information.

I see. Thanks for the clarification .

> > Will that automatically provide the correct string as > MyApplication.ExeName ? Yes.

Great. I thought TCustomApplication would be rather abstract.

Show quoted text 9 lines
> I thing just using the Lazarus NoGUI Widget Type is more appropriate. No, for 2 reasons: 1) It creates unwanted dependencies. 2) It creates the illusion of functionality which isn't actually there. Sooner or later it will bite you in the leg.

OK.

In fact I decently dislike NoGUI as it does not provide an event queue for things like TTimer and thus is not comparable with "really functional" WidgetTypes.

But unfortunately there is no "functional" Widget Type for command line applications.

Of course as I understand that the OP want to do a project dedicated to Windows, he just could do a normal Application and hide the Main Window.

-Michael

Reply by email

Sven Barth
to Michael Schnell
Michael Schnell wrote 6 lines
>> Will that automatically provide the correct string as >> MyApplication.ExeName ? > Yes. Great. I thought TCustomApplication would be rather abstract.

Application.ExeName is a rather abstract functionality (in the end it just works with ParamStr(0) anyway...).

Regards,
Sven

Reply by email

Michael Schnell
to Sven Barth
Sven Barth wrote
Application.ExeName is a rather abstract functionality (in the end it just works with ParamStr(0) anyway...).

Grrr. I meant it might be property that calls an abstract function to force siblings to implement it. (TCustom... classes are often done like that)

-Michael

Reply by email

Sven Barth
to Michael Schnell
Michael Schnell wrote 7 lines
On 08/02/2013 01:15 PM, Sven Barth wrote: > Application.ExeName is a rather abstract functionality (in the end it > just works with ParamStr(0) anyway...). Grrr. I meant it might be property that calls an abstract function to force siblings to implement it. (TCustom... classes are often done like that)

Then you need to express yourself more precisely :P

Regards,
Sven

Reply by email