Delphi/Lazarus: Difference between ParamStr(0) and Application.ExeName
Question by Compi | Last update on 2024-01-12 | Created on 2016-06-07
Not long ago, I have asked the question how to determine the application folder or the path to the own application respectively 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?
Related Topics
Delphi/Lazarus: Command Line Parameter Tutorial Part 2: Receiving
Tutorial | 0 Comments
MIME Types of Microsoft Office File Formats
Info | 0 Comments
Delphi: Read out folder of our own application
Tip | 0 Comments
Delphi: Global Treatment of Errors (Exceptions)
Tutorial | 0 Comments
Delphi/Lazarus: How to set up a Link to a Website in an Application
Tutorial | 0 Comments
Lazarus/Delphi: Width and ClientWidth - Difference
Info | 0 Comments
Delphi/Lazarus: Command Line Parameter Tutorial Part 1: Sending
Tutorial | 0 Comments
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 article on askingbox.com. That’s how it’s done.
In fact, both functions are identical. Application.ExeName even calls ParamStr(0) internally (at least this applies for Windows or Linux applications, Lazarus on Darwin is doing a bit more).
For Application.ExeName, you have to add the unit Forms to make it work, for ParamStr(0), you only need the System unit. So, if you should create an application without Form (without graphical user interface / GUI), you should better user ParamStr(0) instead of including the unit Forms only for that single function.
If you already have included the unit Forms, for Windows or Linux it does not matter. However, you are saving the additional function call with taking ParamStr(0). On MacOS 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.
Last update on 2024-01-12 | Created on 2016-06-07