H
hoperong
Unregistered / Unconfirmed
GUEST, unregistred user!
这段程序是在delphi6中调用chm格式的文件,从别人那里得到,是在delphi5下运行的,可是我在delphi6
下却不能编译通过,请高手帮忙看一下,有什么需要改进的地方,谢谢了
调用Windows系统目录System32下的HHCTRL.OCX,利用其中的HtmlHelpA函数接口可以自行实现HTML HELP帮助。
公共模块代码如下:
unit HTMLHELPCOMMON
?
interface
uses Windows;
?
type
DWORD_PTR = ^DWORD;
?
Function
HtmlHelp(hwndCaller:HWND;strFile:String;
uCommand:UINT; dwDataWORD_PTR ):HWND;
?
procedure CloseHtmlHelp;
?
implementation
uses
SysUtils;
const
HHControlInstance:THandle=0;
dwCookie WORD = 0;
var
HtmlHelpA:function ( hwndCaller:HWND; pszFileChar ;
uCommand:UINT; dwDataWORD_PTR ):HWND;stdcall;
?
function HtmlHelp(hwndCaller:HWND;strFile:String;
uCommand:UINT; dwDataWORD_PTR ):HWND;
var
LFileName:String;
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('Help system not installed!'#13' HTMLHELP cannot displayed!');
@HtmlHelpA := GetProcAddress( HHControlInstance, 'HtmlHelpA');
if @HtmlHelpA = nil then
raise exception.Create('Function HTMLHELP cannot loaded!');
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.
?
两个函数分别初始化和释放调用接口。其它模块只须按约定调用即可。例如:
HtmlHelp( handle, htmlhelpfilename+'::/welcome.htm',$0000, nil);
显示htmlhelpfilename对应的帮助文件的welcome页面。
下却不能编译通过,请高手帮忙看一下,有什么需要改进的地方,谢谢了
调用Windows系统目录System32下的HHCTRL.OCX,利用其中的HtmlHelpA函数接口可以自行实现HTML HELP帮助。
公共模块代码如下:
unit HTMLHELPCOMMON
?
interface
uses Windows;
?
type
DWORD_PTR = ^DWORD;
?
Function
HtmlHelp(hwndCaller:HWND;strFile:String;
uCommand:UINT; dwDataWORD_PTR ):HWND;
?
procedure CloseHtmlHelp;
?
implementation
uses
SysUtils;
const
HHControlInstance:THandle=0;
dwCookie WORD = 0;
var
HtmlHelpA:function ( hwndCaller:HWND; pszFileChar ;
uCommand:UINT; dwDataWORD_PTR ):HWND;stdcall;
?
function HtmlHelp(hwndCaller:HWND;strFile:String;
uCommand:UINT; dwDataWORD_PTR ):HWND;
var
LFileName:String;
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('Help system not installed!'#13' HTMLHELP cannot displayed!');
@HtmlHelpA := GetProcAddress( HHControlInstance, 'HtmlHelpA');
if @HtmlHelpA = nil then
raise exception.Create('Function HTMLHELP cannot loaded!');
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.
?
两个函数分别初始化和释放调用接口。其它模块只须按约定调用即可。例如:
HtmlHelp( handle, htmlhelpfilename+'::/welcome.htm',$0000, nil);
显示htmlhelpfilename对应的帮助文件的welcome页面。