unit GetModuleName;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

// BeginExample: GetModuleName
// Routine: SysUtils.GetModuleName
// Variable: SysInit.HInstance

// BeginCode
{
This example requires a button and a label.  When the user clicks
the button, the GetModuleName function retieves the path and name
of the project executable using the file handle HInstance.
}
function GetUsersFileName: string;
begin
  Result := SysUtils.GetModuleName(HInstance);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Label1.Caption := GetUsersFileName;
end;
// EndCode
// EndExample: GetModuleName
end.
