历史悠久的Delphi高手请回答(100分)

  • 主题发起人 主题发起人 Northwind
  • 开始时间 开始时间
N

Northwind

Unregistered / Unconfirmed
GUEST, unregistred user!
我在网上看到一个访问Chm文件的例子,是Delphi4的,我在Delphi6下编译出错。<br>出错内容提示:Left side connot be assigned to<br>我怀疑要在 uses 中增加引用 Api 函数的描述,但是不知到添加哪一类,清高手指点。<br><br>function HtmlHelp( &nbsp;hwndCaller:HWND; strFile:String; uCommand:UINT; dwData:DWORD_PTR ):HWND;<br>var<br>&nbsp; OcxFileName:String;<br>&nbsp; p:PChar;<br>begin<br>&nbsp; if HHControlInstance=0 then<br>&nbsp; begin<br>&nbsp; &nbsp; OcxFileName := StringOfChar( ' ', 256);<br>&nbsp; &nbsp; p := PChar( OcxFilename );<br>&nbsp; &nbsp; GetSystemDirectory(p,255);<br>&nbsp; &nbsp; StrCat(p,'/HHCTRL.OCX');<br>&nbsp; &nbsp; HHControlInstance := LoadLibrary( P ); &nbsp; &nbsp;//这条语句编译通不过<br>&nbsp; &nbsp; if HHControlInstance = 0 then<br>&nbsp; &nbsp; &nbsp; raise exception.Create('HHCtrl.OCX not installed!'#13' HTMLHELP cannot displayed!');<br>&nbsp; &nbsp; @HtmlHelpA := GetProcAddress( HHControlInstance, 'HtmlHelpA');<br>&nbsp; &nbsp; if @HtmlHelpA = nil then<br>&nbsp; &nbsp; &nbsp; raise exception.Create('Function HTMLHELP cannot loaded!');<br>&nbsp; &nbsp; HtmlHelpA( 0, nil, HH_INITIALIZE, (@dwCookie));<br>&nbsp; end;<br>&nbsp; result := HtmlHelpA( hwndCaller, PChar( strFile ), uCommand, dwData );<br>end;
 
&nbsp; &nbsp;OcxFileName := StringOfChar( ' ', 256);<br>&nbsp; &nbsp; p := PChar( OcxFilename );<br>&nbsp; &nbsp; GetSystemDirectory(p,255);<br>&nbsp; &nbsp; StrCat(p,'/HHCTRL.OCX');<br>&nbsp; &nbsp;&gt;&gt; <br>&nbsp; &nbsp;p:=AllocMem(256);// 刚才记错了<br>&nbsp; &nbsp;GetSystemDirectory(p,255);//要检查 长度 <br>&nbsp; &nbsp;StrCat(p,'HHCTRL.OCX');<br>&nbsp; &nbsp;LoadLibrary(P); &nbsp; &nbsp;<br>&nbsp; &nbsp;<br>&nbsp; &nbsp;
 
to 张大侠<br><br>&nbsp; &nbsp;p:=GetMem(256); &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//此语句出错, Incompatible types<br>&nbsp; &nbsp;GetSystemDirectory(p,255);//要检查 长度 <br>&nbsp; &nbsp;StrCat(p,'HHCTRL.OCX');<br>&nbsp; &nbsp;LoadLibrary(P); &nbsp; &nbsp;<br><br>
 
function HtmlHelp( &nbsp;hwndCaller:HWND; strFile:String; uCommand:UINT; dwData:DWORD_PTR ):HWND;<br>var<br>// &nbsp;OcxFileName:String;<br>&nbsp; p:PChar;<br>begin<br>&nbsp; if HHControlInstance=0 then<br>&nbsp; begin<br>// &nbsp; &nbsp;OcxFileName := StringOfChar( ' ', 256);<br>&nbsp; &nbsp; getmem(p, 255);<br>// &nbsp; &nbsp;p := PChar( OcxFilename );<br>&nbsp; &nbsp; GetSystemDirectory(p,255);<br>&nbsp; &nbsp; StrCat(p,'/HHCTRL.OCX');<br>&nbsp; &nbsp; HHControlInstance := LoadLibrary( P ); &nbsp; &nbsp;//这条语句编译通不过<br>&nbsp; &nbsp; if HHControlInstance = 0 then<br>&nbsp; &nbsp; &nbsp; raise exception.Create('HHCtrl.OCX not installed!'#13' HTMLHELP cannot displayed!');<br>&nbsp; &nbsp; @HtmlHelpA := GetProcAddress( HHControlInstance, 'HtmlHelpA');<br>&nbsp; &nbsp; if @HtmlHelpA = nil then<br>&nbsp; &nbsp; &nbsp; raise exception.Create('Function HTMLHELP cannot loaded!');<br>&nbsp; &nbsp; HtmlHelpA( 0, nil, HH_INITIALIZE, (@dwCookie));<br>&nbsp; end;<br>&nbsp; result := HtmlHelpA( hwndCaller, PChar( strFile ), uCommand, dwData );<br>end;
 
你干脆用p:array[0..255]of ansichar;得了
 
to 木子<br><br>不行,还是<br><br>&nbsp; &nbsp; HHControlInstance := LoadLibrary( P ); &nbsp; &nbsp;//这条语句编译通不过<br>&nbsp; &nbsp; <br>出错内容提示:Left side connot be assigned to<br><br><br>
 
HHControlInstance 是THandle类型才行
 
HHControlInstance:THandle;应该就OK了
 
{$j+}<br>加上这一句。<br>
 
看看HHControlInstance在哪个单元,如何定义的
 
&nbsp;建议重新定义一个变量tempInstance:Thandle代替HHControlInstance,因为这段程序本身是找出动态库程序入口点并执行,<br>所以可以不考虑HHControlInstance的值,示例如下:<br>function HtmlHelp( &nbsp;hwndCaller:HWND; strFile:String; uCommand:UINT; dwData:DWORD_PTR ):HWND;<br>var<br>&nbsp; OcxFileName:String;<br>&nbsp; p:PChar;<br>&nbsp; tempInstance:THandle;<br>begin<br>&nbsp; if HHControlInstance=0 then<br>&nbsp; begin<br>&nbsp; &nbsp; OcxFileName := StringOfChar( ' ', 256);<br>&nbsp; &nbsp; p := PChar( OcxFilename );<br>&nbsp; &nbsp; GetSystemDirectory(p,255);<br>&nbsp; &nbsp; StrCat(p,'/HHCTRL.OCX');<br>&nbsp; &nbsp; tempInstance := LoadLibrary( P ); &nbsp; &nbsp;//这条语句编译通不过<br>&nbsp; &nbsp; if tempInstance = 0 then<br>&nbsp; &nbsp; &nbsp; raise exception.Create('HHCtrl.OCX not installed!'#13' HTMLHELP cannot displayed!');<br>&nbsp; &nbsp; @HtmlHelpA := GetProcAddress( tempInstance, 'HtmlHelpA');<br>&nbsp; &nbsp; if @HtmlHelpA = nil then<br>&nbsp; &nbsp; &nbsp; raise exception.Create('Function HTMLHELP cannot loaded!');<br>&nbsp; &nbsp; HtmlHelpA( 0, nil, HH_INITIALIZE, (@dwCookie));<br>&nbsp; end;<br>&nbsp; result := HtmlHelpA( hwndCaller, PChar( strFile ), uCommand, dwData );<br>end;
 
听课!各位大哥,收下小弟吧! 先BAI师了! &nbsp;:D
 
后退
顶部