Skip to content

Instantly share code, notes, and snippets.

@freeonterminate
Last active June 26, 2022 05:45
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save freeonterminate/2f7b2e29e40fa30ed3c4 to your computer and use it in GitHub Desktop.
Save freeonterminate/2f7b2e29e40fa30ed3c4 to your computer and use it in GitHub Desktop.
TApplication に ExeName メソッドを追加するコード
(*
* ExeName method is added to TApplication.
*
* Made by HOSOKAWA Jun.
*
* CONTACT
* Twitter @pik or freeonterminate@gmail.com
*
* LAST UPDATE
* 2015/12/15 First Release
*
* PLATFORM
* Windows, OS X, iOS, Android
* Delphi (XE8 <- maybe) 10 seattle
* Maybe, Appmethod and C++Builder
*
* ORIGINAL SOURCE
* https://gist.github.com/freeonterminate/2f7b2e29e40fa30ed3c4
*
* HOW TO USE
* 1. uses FMX.ApplicationHelper;
* 2, You want to Exe Path, call Application.ExeName !
*)
unit FMX.ApplicationHelper;
interface
uses
FMX.Forms;
type
TApplicationHelper = class helper for TApplication
public
function ExeName: String;
end;
implementation
{$IFDEF ANDROID}
uses
System.SysUtils
, Androidapi.Helpers
;
{$ENDIF}
{ TApplicationHelper }
function TApplicationHelper.ExeName: String;
begin
Result := ParamStr(0);
{$IFDEF ANDROID}
if (Result.IsEmpty) then
Result := JStringToString(TAndroidHelper.Context.getPackageCodePath);
{$ENDIF}
end;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment