Problem with Application.HelpFile and ExtractFilePath(Application.ExeName)
Posted on 2002-04-19
In the *.dpr file of my application under construction there is this
Application.HelpFile := 'C:\MyFiles\Programming\Projects\Sourcefiles\MyApp\MyApp.HLP';
I guess this code line has been created by the settings of my Delphi 6.0 Professional:
But actually I don't like this string constant. If I give my application to other users,
I can't be sure that they will install my application into the same directory as this is
the case on my PC.
And if my application is really installed to another directory, the code line above will
cause a run-time error, because the helpfile can't be found.
This is the reason why I try to code a more flexible solution.
I tried to accomplish my goal with this statement:
Application.HelpFile:= ExtractFilePath(Application.ExeName) + 'MyApp.HLP';
But as soon as I edit the *.dpr file, and make the described changes, I immediately get this error message:
Error in module myprogram: The Call of Application.CreateForm is missing or is not correct.
Do you know how I can solve this problem? I think you will agree with me tzhat it is is really bad to assume that
the users of my program have the same directories on their computer. So I have to find a method to assign to path
to the help file dynamically. But obviously Delphi becomes rather angry, if anyone tries
to edit the project files.