是否有任何提示可以让我将Microsoft帮助查看器与Delphi应用程序集成(2009年起)。
由于
答案 0 :(得分:1)
答案 1 :(得分:1)
我假设您的意思是HtmlHelp,因为WinHelp
已被弃用,并且5年前已停止在Windows中发布。
以下是我添加到ApplicationEvents
对象的OnHelp
事件处理程序的代码:
function TdmGlobal.ApplicationEvents1Help(Command: Word; Data: Integer;
var CallHelp: Boolean): Boolean;
var
HelpFile: string;
LocalFile: string;
HCommand : word;
begin
CallHelp := False;
Result := False;
//i've named the help file the same as the executable, but with CHM extension
HelpFile := ChangeFileExt(Application.ExeName, '.chm');
if not FileExists(HelpFile) then
Exit;
//Starting in 2003 HtmlHelp will no longer work from a network drive.
//Copy the file to the local machine's temp folder if it's sitting on a network share
if PathIsNetworkPath(HelpFile) then
begin
LocalFile := IncludeTrailingBackslash(GetTemporaryPath)+ExtractFilename(HelpFile);
if (not FileExists(LocalFile)) then
begin
try
CopyFile(PChar(HelpFile), PChar(LocalFile), False);
except
Exit;
end;
end
else
begin
if (GetUncompressedFileSize(HelpFile) <> GetUncompressedFileSize(LocalFile)) then
try
CopyFile(PChar(HelpFile), PChar(LocalFile), False);
except
//Exit; eat it
end;
end;
HelpFile := LocalFile;
end;
{translate WinHelp --> HTMLHelp}
case Command of
HELP_CONTENTS:
begin
HCommand := HH_DISPLAY_TOC;
Data := 0;
end; {HELP_CONTENTS..}
HELP_CONTEXT : HCommand := HH_HELP_CONTEXT;
HELP_CONTEXTPOPUP : HCommand := HH_HELP_CONTEXT;
HELP_FINDER : HCommand := HH_DISPLAY_TOPIC;
HELP_KEY : HCommand := HH_DISPLAY_INDEX;
HELP_QUIT :
begin
HCommand := HH_CLOSE_ALL;
Data := 0;
end; {HELP_QUIT..}
else
begin {default}
HCommand := HH_DISPLAY_TOPIC;
Data := 0;
end; {default..}
end; {case Command..}
hhCtrl.HtmlHelp(GetDesktopWindow(), HelpFile, HCommand, Data);
end;
hhCtrl.pas
包含许多常量,以及函数:
function HtmlHelp(
hwndCaller: HWND;
szFile: AnsiString;
uCommand: UINT;
dwData: DWORD): HWND; stdcall; external 'hhctrl.ocx' name 'HtmlHelpA'; {external API call}