Solved

how to et current file name and path

Posted on 2003-11-15
9
492 Views
Last Modified: 2010-05-18
how to know the path and file name of my project while it's running?
i'm afraid that someone will rename it
0
Comment
Question by:petervn
  • 2
  • 2
  • 2
  • +2
9 Comments
 
LVL 3

Expert Comment

by:cwp
Comment Utility
The path and filename of your program will be stored in the ParamStr(0) variable.
0
 
LVL 8

Accepted Solution

by:
gmayo earned 50 total points
Comment Utility
ShowMessage(Application.ExeName);

That includes the both the exe name and path information.

Geoff M.
0
 
LVL 3

Expert Comment

by:cwp
Comment Utility
Whoops. Did I say variable? I meant function.
0
 

Expert Comment

by:13_th
Comment Utility
var FilePath,FileName:string;
...

FilePath:= ExtractFilePath(Application.ExeName);
FileName:= ExtractFileName(Application.ExeName);
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 6

Expert Comment

by:DaFox
Comment Utility
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
 

Expert Comment

by:13_th
Comment Utility
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
 
LVL 6

Expert Comment

by:DaFox
Comment Utility
:-D
0
 
LVL 8

Expert Comment

by:gmayo
Comment Utility
Now that is b*stardisation if ever I saw it...

Geoff M.
0
 

Expert Comment

by:Cyclovenom
Comment Utility

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

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now