how to et current file name and path

how to know the path and file name of my project while it's running?
i'm afraid that someone will rename it
petervnAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cwpCommented:
The path and filename of your program will be stored in the ParamStr(0) variable.
0
gmayoCommented:
ShowMessage(Application.ExeName);

That includes the both the exe name and path information.

Geoff M.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
cwpCommented:
Whoops. Did I say variable? I meant function.
0
OWASP: Threats Fundamentals

Learn the top ten threats that are present in modern web-application development and how to protect your business from them.

13_thCommented:
var FilePath,FileName:string;
...

FilePath:= ExtractFilePath(Application.ExeName);
FileName:= ExtractFileName(Application.ExeName);
0
DaFoxCommented:
Application.ExeName internally calls ParamStr(0), but it doesn't work with console apps (or wherever you don't have the TApplication object), so I'd rather follow Geoff's hint.
Windows automatically adds the path + filename of a launched app as the first parameter (ParamStr() is zero-based).

Markus
0
13_thCommented:
var FilePath,FileName:string;
...

FilePath:= ExtractFilePath(Application.ExeName);
FileName:= ExtractFileName(Application.ExeName);

or

//only for app not usage tapplication

FilePath:= ExtractFilePath(ParamStr(0));
FileName:= ExtractFileName(ParamStr(0));

0
DaFoxCommented:
:-D
0
gmayoCommented:
Now that is b*stardisation if ever I saw it...

Geoff M.
0
CyclovenomCommented:

Taken from Key Objects Library (KOL)

function GetStartDir : String;
var Buffer:array[0..260] of Char;
    I : Integer;
begin
  I := GetModuleFileName( 0, Buffer, Sizeof( Buffer ) );
  for I := I downto 0 do
    if Buffer[ I ] = '\' then
    begin
      Buffer[ I + 1 ] := #0;
      break;
    end;
  Result := Buffer;
end;
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.