Solved

how to et current file name and path

Posted on 2003-11-15
9
493 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
ID: 9754152
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
ID: 9754250
ShowMessage(Application.ExeName);

That includes the both the exe name and path information.

Geoff M.
0
 
LVL 3

Expert Comment

by:cwp
ID: 9754281
Whoops. Did I say variable? I meant function.
0
 

Expert Comment

by:13_th
ID: 9754443
var FilePath,FileName:string;
...

FilePath:= ExtractFilePath(Application.ExeName);
FileName:= ExtractFileName(Application.ExeName);
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Expert Comment

by:DaFox
ID: 9754568
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
ID: 9754722
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
ID: 9754792
:-D
0
 
LVL 8

Expert Comment

by:gmayo
ID: 9754884
Now that is b*stardisation if ever I saw it...

Geoff M.
0
 

Expert Comment

by:Cyclovenom
ID: 9760388

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Need Delphi function to get Youtube video title 5 225
Delphi OLE Error 8 93
oracle global variables 4 63
When i run adoquery my application freezes 26 150
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

911 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

20 Experts available now in Live!

Get 1:1 Help Now