Christopher Chase
Christopher Chase

Reputation: 2890

Get BPL File Name

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)

Upvotes: 4

Views: 1131

Answers (2)

Jason Southwell
Jason Southwell

Reputation: 361

Example use of GetModuleFileName:

function  DLLFileName : string;
begin
  SetLength(Result,MAX_PATH);
  GetModuleFileName(HInstance,PCHar(Result),MAX_PATH);
  SetLength(Result,StrLen(PChar(Result)));
end;

Upvotes: 1

Rob Kennedy
Rob Kennedy

Reputation: 163267

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).

Upvotes: 8

Related Questions