2
votes

I am trying to add my new HTML Help file to the Delphi 10 Seattle. This requires registering your own menu item, according to the documentation:

Third-Party Help Menu Item (Delphi)

The only thing I am missing is how to determine the installation directory of the component package at runtime (or design/register time actually), so that I can define the Path\to\your\local\help\file in practice. My help files will be installed relative to the .bpl files so I would just need to find that path.

What I can figure out is that I should probably use the ToolsAPI IOTAPackageServices interface maybe?

2
I believe it's just to be relative to the package, no absolute path. EDIT Actually that might not be the case, after looking at that link more. Delphi documentation has always had a habit of omitting important pieces of information for real-life scenarios. - Jerry Dodge
Yeah, the version of that doc page that was shipped with Delphi 10 contains code that did not even compile... On the online page the code seems to be fixed, but is still not very neat. - Jouni Aro
Also, I have no idea whether the context sensitive component help should work - at least it does not work with Indy components that are shipped with Delphi 10 - and I can't make it work for mine either - Jouni Aro

2 Answers

3
votes

You can get your package's executable file name by calling SysUtils.GetModuleName(HInstance).

1
votes

I managed to use myself this version, which also works, but is just too complicated:

var
  PackageServices: IOTAPackageServices;
  I: Integer;
  Package: IOTAPackageInfo;
...
  if Supports(BorlandIDEServices, IOTAPackageServices, PackageServices) then
  begin
    I := 0;
    while True do
    try
      Package := PackageServices.Package[I];
      if Package = nil then
        break;
      if StartsStr('MyProduct', Package.Name) then
      begin
        // The help file is on the "side" directory of the package
        HelpFilePath := ExtractFilePath(Package.FileName) + '..\Help\MyProduct.chm';
      end;
      Inc(I);
    except
        break;
    end;
  end;