4

How call help from chm files in Delphi 7 program?

Application.HelpFile := 'd:\help.chm';
Application.HelpCommand(HELP_CONTEXT, 10);

result is

Why can't I get Help from this program?

The Help for this program was created in Windows Help format, which depends on a feature that isn't included in this version of Windows. However, you can download a program that will allow you to view Help created in the Windows Help format.

For more information, go to the Microsoft Help and Support website.

RRUZ
  • 134,889
  • 20
  • 356
  • 483
barbaris
  • 514
  • 8
  • 25
  • It would help also if you told us what Windows version you're getting that error message from, since that seems to be part of the issue. What are you using (which unit) that allows you to access HTML Help? – Ken White Mar 14 '13 at 14:08

2 Answers2

6

The problem is that Delphi 7, by default, assumes that help files use the old WinHelp format that was not shipped with Vista. Even though your help file has the .chm extension, Delphi tries to show it using WinHelp commands. And since WinHelp isn't there, you get the error message that you reported.

There are various ways to get the help system to show HTML help. For example, a common technique is to implement an OnHelp handler for the Application object and route the help to calls to the HtmlHelp API. I gave a very simple example of that in a recent answer.

Community
  • 1
  • 1
David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • @MarcovandeVoort Yes that's a good link. We used that code when we were on D6. I think the `OnHelp` problem was fixed in D7 though. Not that I ever used D7. – David Heffernan Mar 19 '13 at 09:54
1

To open CHM file I use the following code:

    ShellExecute(Handle, 'open', PChar(ExtractFilePath(Application.ExeName) + 'help.chm'), nil, nil, SW_SHOW);
MaxSh
  • 31
  • 1
  • 2