Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get BPL File Name

Tags:

delphi

bpl

From within a BPL, is it possible to get its own file name? e.g. C:\foo\bar.bpl

(dynamically loaded and delphi7, if it matters)

like image 308
Christopher Chase Avatar asked Jan 24 '23 01:01

Christopher Chase


2 Answers

Call GetModuleFileName. For the module handle, use SysInit.HInstance. Passing zero will give you the host EXE's file name instead, also known as ParamStr(0).

like image 91
Rob Kennedy Avatar answered Jan 26 '23 00:01

Rob Kennedy


Example use of GetModuleFileName:

function  DLLFileName : string;
begin
  SetLength(Result,MAX_PATH);
  GetModuleFileName(HInstance,PCHar(Result),MAX_PATH);
  SetLength(Result,StrLen(PChar(Result)));
end;
like image 33
Jason Southwell Avatar answered Jan 25 '23 22:01

Jason Southwell