unit C_HtmlHelp;interfaceuses
SysUtils,windows;constHH_HELP_CONTEXT = $0F;HH_CLOSE_ALL = $12;HH_INITIALIZE = $1C;HH_UNINITIALIZE = $1D;
type
DWORD_PTR = ^DWORD;Function HtmlHelp(hwndCaller:HWND;strFile:String;uCommand:UINT; dwData:DWORD_PTR ):HWND;
{调用方法如:
HtmlHelp( handle, 'med20.chm'+'::/index.htm',$0000, nil); }procedure CloseHtmlHelp;implementation
const
HHControlInstance : THandle=0;
dwCookie :DWORD = 0;var
HtmlHelpA:function ( hwndCaller:HWND; pszFile:PChar;uCommand:UINT; dwData:DWORD_PTR ):HWND;stdcall;function HtmlHelp(hwndCaller:HWND;strFile:String;
uCommand:UINT; dwData:DWORD_PTR ):HWND;
var
LFileName : String;
p : PChar;
begin
if HHControlInstance=0 then
begin
LFileName := StringOfChar(' ', 256); 
p := PChar(LFilename);
GetSystemDirectory(p,255);
StrCat(p,'\HHCTRL.OCX');
HHControlInstance := LoadLibrary( P ); {执行出错}
if HHControlInstance = 0 then
raise exception.Create('帮助系统没有安装!'#13' HTML格式的帮助不能显示!');
@HtmlHelpA := GetProcAddress( HHControlInstance, 'HtmlHelpA');
if @HtmlHelpA = nil then
raise exception.Create('函数 HTMLHELP 不能调用!');
HtmlHelpA( 0, nil,$001C , (@dwCookie));
end;
result := HtmlHelpA( hwndCaller, PChar( strFile ), uCommand, dwData );
end;procedure CloseHtmlHelp;
begin
if HHControlInstance<>0 then
begin
HtmlHelpA( 0, nil, $001D, DWORD_PTR(dwCookie));
FreeLibrary(HHControlInstance);
end;
end;end.