0 0 Votes

Delphi/Lazarus: Difference between ParamStr(0) and Application.ExeName

Question by Compi | 07/06/2016 at 19:14

Not long ago, I have asked the question how to determine the application folder or the path to the own application and how to get the name of the EXE file of the own application.

Both can be solved using Application.ExeName as a well as Paramstr(0).

So far as I have understood this, ParamStr(0) and Application.ExeName seem to be the same. But where is the difference? And why do we need two functions doing the same?

And which of those functions should I use better? Are there any advantages or disadvantages speaking for the one or the other of them?

ReplyPositiveNegative

Delphian

Show Profile | Message
Avatar
1Best Answer
1 Vote

In fact, both functions are identical. Application.ExeName is even calling ParamStr(0) internally (at least when using Windows or Linux applications, Lazarus on Darwin is doing some more).

For Application.ExeName, you have to add the unit Forms to make it work, for ParamStr(0), you only need to the System unit. So, if you should create an application without Form, you should better user ParamStr(0) instead of including the unit Forms only for that function.

If you already have included the Forms unit, for Windows or Linux it does not matter. However, you are saving the additional function call with taking ParamStr(0). On Mac OS X I would rather tend to Application.ExeName if you need some of the additional code.

In doubt, I would recommend taking ParamStr(0) for that task.
07/06/2016 at 19:27

ReplyPositive Negative
Reply

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own articles on askingbox.com. How to do.