Solved

how to et current file name and path

Posted on 2003-11-15
9
494 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Expert Comment

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

FilePath:= ExtractFilePath(Application.ExeName);
FileName:= ExtractFileName(Application.ExeName);
0
 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Path  to current project in Delphi. 2 80
Magic Software info 18 131
Delphi 2 60
scroll down TListBox component in Delphi 1 11
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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

810 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