Link to home
Start Free TrialLog in
Avatar of mathes
mathes

asked on

Problem with Application.HelpFile and ExtractFilePath(Application.ExeName)

Hi experts,

In the *.dpr file of my application under construction there is this
line:

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:

 Project/Options/Application/Helpfile

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.



Avatar of kretzschmar
kretzschmar
Flag of Germany image

do this
Application.HelpFile:= ExtractFilePath(Application.ExeName) + 'MyApp.HLP';

im the oncreate-event of your mainform

meikl ;-)
ASKER CERTIFIED SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mathes
mathes

ASKER

Dear Meikl,

thank you for your input. Your second idea works perfectly for me. I don't know if your other suggestion - changing
the OnCreate-event is applicaple. As far as I know a *.dpr file has no OnCreate-event.