22 Votes

Delphi/Lazarus: Get File Name of own Application

Question by Compi | Last update on 2024-01-12 | Created on 2016-06-06

Is there a way to find out, determine or retrieve the name of the EXE file of your own program? For example "MyApp.exe" or whatever the name is?

Of course, theoretically, I know how I have named my own EXE, but, however, the user could have named the program file to any other arbitrary name. And this is the case I would like to check for.

ReplyPositiveNegative
3Best Answer5 Votes

You can read out the EXE file of your own application by using Paramstr(0) as a well as with Application.ExeName.

However, both also provide you additionally with the complete application path, so that you have to divide path and program name from each other:

var
  MyEXE: string;
begin

  MyEXE := ExtractFileName(Application.ExeName);

  // or

  MyEXE := ExtractFileName(Paramstr(0));

end;

With ExtractFileName(), you can cut off the path from your program file so that you will only get the name of your EXE.
Last update on 2024-01-12 | Created on 2016-06-07

ReplyPositive Negative
Reply

Related Topics

Rename File to its Folder Name

Tutorial | 0 Comments

PHP: File Download Script

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.