请高手看看我的程序为什么不对啊!!(100分)

  • 主题发起人 主题发起人 lsc0530
  • 开始时间 开始时间
L

lsc0530

Unregistered / Unconfirmed
GUEST, unregistred user!
我照书敲的程序可是总是报以下错误<br>[Error] Unit1.pas(17): Declaration of 'CopyCallback' differs from declaration in interface 'ICopyHookA'<br>请那为给个答案 谢了<br><br>library Project2;<br><br>uses<br>&nbsp; ComServ,<br>&nbsp; Unit1 in 'Unit1.pas';<br><br>exports<br>&nbsp; DllGetClassObject,<br>&nbsp; DllCanUnloadNow,<br>&nbsp; DllRegisterServer,<br>&nbsp; DllUnregisterServer;<br><br>{$R *.RES}<br><br>begin<br>end.<br><br>unit Unit1;<br>&nbsp;interface<br>uses<br>Windows,Messages,ComObj,ComServ,SysUtils,Classes,Graphics,Controls,Forms,Dialogs,shellapi,shlobj,ActiveX;<br><br>const<br>CLSID_PascalcopHook:TGUID='{80A06FA0-7df2-11D0-98D0-444553540000}';<br><br><br>type<br>TpasCopyHooK=class(TComObject,ICopyHook)<br>public<br>function CopyCallback(Hwnd:THandle;wFunc,<br>wFlags:UINT;pszSrcFile:PAnsiChar;dwSrcAttribs:DWORD;<br>pszDestFile:PAnsiChar;dwDestAttribs:DWORD):UINT;stdcall;<br>end;<br><br>type<br>ICopyHookA=interface(IUnKnown)<br>function CopyCallback(Wnd:Hwnd;wFunc,<br>wFlags:UINT;pszSrcFile:PAnsiChar;dwSrcAttribs:DWORD;<br>pszDestFile:PAnsiChar;dwDestAttribs:DWORD):UINT;<br>end;<br>ICopyHook=ICopyHookA;<br><br><br>implementation<br>&nbsp;function TpasCopyHooK.CopyCallback(Hwnd:THandle;wFunc,wFlags:UINT;pszSrcFile:PAnsiChar;dwSrcAttribs:DWORD;pszDestFile:PAnsiChar;dwDestAttribs:DWORD):UINT;stdcall;<br>var<br>Msg:string;<br>MessType:TMsgDlgType;<br>begin<br>Application.Handle:=Hwnd;<br>Msg:='';<br>MessType:=mtconfirmation;<br>case wFunc of<br>FO_COPY:<br>begin<br>Msg:=Format('Are yopu &nbsp;sure you want to copy the %s'+'folder to the %s destination ',[PszSrcFile,pszDestFile]);<br>end;<br>FO_DELETE:<br>begin<br>Msg:=Format('Are yopu &nbsp;sure you want to del the %s',[PszSrcFile,pszDestFile]);<br>end;<br>end;<br>if msg&lt;&gt;'' then<br>result:=messageDlg(Msg,MessType,mbYesNoCancel,0 )<br>else<br>result:=id_Yes;<br>end;<br>initialization<br>TComObjectFactory.Create(comserver,TPasCopyHook,CLSID_PascalcopHook,'PasalCopyHook','CopyHook Demo from Mastering Delphi 3',ciMultiInstance);<br><br><br>end.<br>
 
接口ICopyHookA已經定義了CopyCallback函數<br>
 
pdb 你能说的在明白一点吗?
 
将<br>type<br>ICopyHookA=interface(IUnKnown)<br>function CopyCallback(Wnd:Hwnd;wFunc,<br>wFlags:UINT;pszSrcFile:PAnsiChar;dwSrcAttribs:DWORD;<br>pszDestFile:PAnsiChar;dwDestAttribs:DWORD):UINT;<br>end;<br>中的<br>function CopyCallback(Wnd:Hwnd;wFunc,<br>wFlags:UINT;pszSrcFile:PAnsiChar;dwSrcAttribs:DWORD;<br>pszDestFile:PAnsiChar;dwDestAttribs:DWORD):UINT;<br>end;<br>去掉试一下!
 
joysun 我试了还不行!
 
那么去掉后的错误是什么?
 
谢谢 你的帮忙 !已经有人给解决了<br>需要将两个声名互换位置
 
to 楼主:<br>&nbsp; &nbsp;呵呵,够大方!竟然贴了两个帖子,问题解决了。看看那个帖子的我的注释吧。<br>http://www.delphibbs.com/delphibbs/dispq.asp?lid=1551713
 
对比下CopyCallback函数和你想要调用的函数的差别,如果没有差别。<br>就是有两个地方声明了该函数,而你在调用的时候没有明确指定是调用那一个。<br>在函数调用前面明确指定函数据所在的unit。
 
后退
顶部