如何在Delphi中调用*.chm(100分)

  • 主题发起人 主题发起人 Enlightenment
  • 开始时间 开始时间
E

Enlightenment

Unregistered / Unconfirmed
GUEST, unregistred user!
我想要在Delphi中调用*.chm的具体实例,各位能否写几句示例代码先?拜托!拜托!
 
只需一行代码

ShellExecute(0, PChar('Open'), PChar('hh.exe'), PChar('你的文件.CHM'), nil, SW_SHOW);

千万不要忘了给分:)
 
还要 uses shellapi;
 
uses shellapi;
ShellExecute(0,'open','C:/netants/NetAnts.chm',nil,nil,SW_SHOWNORMAL);
 
or
WinExec('hh C:/netants/NetAnts.chm',SW_SHOWNORMAL);
 
Sorry! 没说清楚,是要包括“显示内容”、“显示索引”、“显示指定页码”等功能。
而且,单单用Shellexecute不能够达到帮助文件与程序的关联。
即每次调用不产生多个副本,且在程序结束时能够自动关闭 .chm文件,
许多程序都可以做到的。

还请各位帮忙!
 
哈哈
没人会啦?
这儿有做商业软件的朋友吗
发发言吧
做项目软件的才不会费这个神呢
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,shellapi;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
hh: HINST;
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
if hh = 0 then
hh := ShellExecute(application.Handle,'open','C:/netants/NetAnts.chm',nil,nil,SW_SHOW);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
hh := 0;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
sendmessage(FindWindow(nil,'网络蚂蚁使用手册'),wm_close,0,0);
end;

end.
 

pqx的方法!???这样做的遗留问题:
1.打开一次chm以后,用户操作又要打开某指定ID的页码。如何是好?
2.若这个.chm不是我的程序打开的,程序关闭时的做法岂不是多管闲事。

先要感谢各位的回答,但我是希望得到一个比较“正常”的处理方法。
当然,只要能拿到耗子且不留弊病也行。

还请大家多多帮忙!问题解决,保证分数全部送出。
 
楼上的大虾所说的是打开CHM...
不过在CHM中实现跳转到某主题怎么办...
我正在思考中...
 
我有例子,给分,来信。
eagleboost@21cn.com
 
快点给分,好回家过年

HTMLHelp API Reference
The HtmlHelp API currently resides in the file HTMLHELP.DLL, however this is very likely to be moved to a different DLL before HTML Help ships. If you are not using GetProcAddress to get a pointer to the HtmlHelp function, then you must plan on changing the library you link to.

The functionality provided by the HtmlHelp API resides in the file HHCTRL.OCX. Because this functionality requires loading various other DLLs such as ole32.dll, the API itself resides in a DLL that requires no additional DLLs to be loaded. Only when the API is actually called will ole32 and other DLLs be loaded.

The HtmlHelp API is modeled after the WinHelp API function to make it easy to convert existing programs to use HTML Help instead of WinHelp to display their help. By the time HTML Help ships, there will also be an IHHWindow interface that can be used in place of the HtmlHelp API. This can be used by programs that already load OLE32.DLL or by programs like Visual Basic.

In its simplest form, the HtmlHelp API creates a child window which in turn hosts SHDOCVW and displays the HTML file you specify. The window is a child of whatever parent window you specify, and will automatically stay on top of that parent window, and close when the parent window is closed. You can also take complete control of the window-creation process by defining the window styles, coordinates, caption, and display state. This means you can embed SHDOCVW even in a non-OLE activated program.

SYNTAX

HWND HtmlHelp(HWND hwndCaller, LPCSTR pszFile, UINT uCommand, DWORD dwData);

hwndCaller
Specifies the handle of the window calling the HtmlHelp API. If the HtmlHelp API call results in messages being sent from the HTML Help window, they will be sent to this window handle.
pszFile
Specifies an HTML file, a URL, a compiled HTML file, or a window definition (preceeded with a ‘>’ character). If the command being used does not require a file or URL, this value may be NULL.
uCommand
Specifies the action to perform. See the Comments section for details.
dwData
Specifies any data that may be required based on the value of the uCommand parameter.
Comments

太长了,自己查msdn帮助吧
在delphi中的函数定义
Function HtmlHelpA(hwnd:integer;lpHelpFile:string;wCommand:integer;dwData:string) :integer;stdcall;External 'hhctrl.ocx';
wCommand要自己查msdn中需要的参数,然后换成0、1这些
使用参数
Command Description pszFile dwData
HH_DISPLAY_TOPIC Displays an HTML file. If a window type is not specified, a default window type is used. If the window type or default window type is already being displayed, the HTML file will replace what is currently being displayed. File, URL, or compiled HTML file. If the greater then character (>) is used, it must be followed by the name of the window type to display the topic in. May be zero or a pointer to a File, URL, or compiled HTML file. This parameter may be a pointer to a filename within a compiled HTML file if the pszFile parameter points to that compiled HTML file.

HtmlHelpA(Handle,'c:/htmlhelp2/rshelp.chm',0,'欢迎.htm');
 
多人接受答案了。
 
后退
顶部