Mirror

Application help file set properly (Views: 711)


Problem/Question/Abstract:

Delphi provides a dialog box to set the application help file. Click Project -> Options and select the Application tab. If you click [Browse] to locate the help file of your application, Delphi sets the help file name including the full path. When you deploy the application, the help file is probably not found because the installation path on your user's computer is not the same.

Answer:

You must specify the help file name without a path or with a relative path. If the help is located in the same directory as the application exe, simply omit the path. If it is located in a sub-directory, specify a relative path. For instance, enter

./help/myhelpfile.hlp

in the dialog box, if there is a sub-directory called "help" below your application's installation folder.

Problem solved? Not completely. This solution works as long as the current directory of your application is the default directory of your application (one where the exe file is installed). This is typically the case, but the current directory may change while your application is running. A call to SetCurrentDir(newdirname) for instance, changes that.

But Windows provides a solution for this. You can enter the path to your help file in the Windows registry. If you do, specify only the help file name in Delphi, no path at all. Then modify the registry key

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Help

and enter a new key for your help file which specifies the path to it.

A third way (and my preferred one) to specify the application help file is to code it manually. It's a single code line you add to the Create event of your main form and you don't have to worry about current directories or registry entries:

procedure TMainForm.FormCreate(Sender: TObject);
begin
  Application.HelpFile :=
    ExtractFileDir(Application.Exename) +
    '\help\HilfeDatei.hlp';
end;

<< Back to main page