we can take advantage of the position of the folder of the application that we are making. for example calling the help file, call the report file, database access and so forth by utilizing  application.exename

  • create new application
  • add 3 edit to form
  • add button to form
  • double click button1
  • write this code
procedure TForm1.Button1Click(Sender: TObject);
 begin
 caption:=application.exename;
 edit1.Text:=application.exename;
 edit2.Text:=extractfilepath(application.exename);
 edit3.Text:=extractfilename(application.exename);
 end;

 

delphionderdils

 

source code

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes,
  Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
caption:=application.exename;
edit1.Text:=application.exename;
edit2.Text:=extractfilepath(application.exename);
edit3.Text:=extractfilename(application.exename);
end;

end.

 

form

object Form1: TForm1
  Left = 192
  Top = 124
  Width = 463
  Height = 203
  Caption = 'Form1'
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Button1: TButton
    Left = 40
    Top = 120
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 0
    OnClick = Button1Click
  end
  object Edit1: TEdit
    Left = 24
    Top = 16
    Width = 401
    Height = 21
    TabOrder = 1
    Text = 'Edit1'
  end
  object Edit2: TEdit
    Left = 24
    Top = 40
    Width = 401
    Height = 21
    TabOrder = 2
    Text = 'Edit2'
  end
  object Edit3: TEdit
    Left = 24
    Top = 64
    Width = 249
    Height = 21
    TabOrder = 3
    Text = 'Edit3'
  end
end

 

 

Print Friendly