简体   繁体   English

如何在Delphi 7中使用chm?

[英]How to use chm in Delphi 7?

How call help from chm files in Delphi 7 program? 如何在Delphi 7程序中从chm文件调用帮助?

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. 该程序的帮助是以Windows帮助格式创建的,该格式取决于此Windows版本中未包含的功能。 However, you can download a program that will allow you to view Help created in the Windows Help format. 但是,您可以下载一个程序,该程序将允许您查看以Windows帮助格式创建的帮助。

For more information, go to the Microsoft Help and Support website. 有关更多信息,请访问Microsoft帮助和支持网站。

The problem is that Delphi 7, by default, assumes that help files use the old WinHelp format that was not shipped with Vista. 问题在于,默认情况下,Delphi 7假定帮助文件使用Vista附带的旧WinHelp格式。 Even though your help file has the .chm extension, Delphi tries to show it using WinHelp commands. 即使您的帮助文件具有.chm扩展名,Delphi也会尝试使用WinHelp命令来显示它。 And since WinHelp isn't there, you get the error message that you reported. 而且由于WinHelp不存在,您将收到报告的错误消息。

There are various ways to get the help system to show HTML help. 有多种方法可以获取帮助系统以显示HTML帮助。 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. 例如,一种常见的技术是为Application对象实现OnHelp处理程序,并将帮助路由到对HtmlHelp API的调用。 I gave a very simple example of that in a recent answer . 我在最近的回答中给出了一个非常简单的例子。

要打开CHM文件,请使用以下代码:

    ShellExecute(Handle, 'open', PChar(ExtractFilePath(Application.ExeName) + 'help.chm'), nil, nil, SW_SHOW);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM