L
lsc0530
Unregistered / Unconfirmed
GUEST, unregistred user!
我照书敲的程序可是总是报以下错误
[Error] Unit1.pas(17): Declaration of 'CopyCallback' differs from declaration in interface 'ICopyHookA'
请那为给个答案 谢了
library Project2;
uses
ComServ,
Unit1 in 'Unit1.pas';
exports
DllGetClassObject,
DllCanUnloadNow,
DllRegisterServer,
DllUnregisterServer;
{$R *.RES}
begin
end.
unit Unit1;
interface
uses
Windows,Messages,ComObj,ComServ,SysUtils,Classes,Graphics,Controls,Forms,Dialogs,shellapi,shlobj,ActiveX;
const
CLSID_PascalcopHook:TGUID='{80A06FA0-7df2-11D0-98D0-444553540000}';
type
TpasCopyHooK=class(TComObject,ICopyHook)
public
function CopyCallback(Hwnd:THandle;wFunc,
wFlags:UINT;pszSrcFileAnsiChar;dwSrcAttribsWORD;
pszDestFileAnsiChar;dwDestAttribsWORD):UINT;stdcall;
end;
type
ICopyHookA=interface(IUnKnown)
function CopyCallback(Wnd:Hwnd;wFunc,
wFlags:UINT;pszSrcFileAnsiChar;dwSrcAttribsWORD;
pszDestFileAnsiChar;dwDestAttribsWORD):UINT;
end;
ICopyHook=ICopyHookA;
implementation
function TpasCopyHooK.CopyCallback(Hwnd:THandle;wFunc,wFlags:UINT;pszSrcFileAnsiChar;dwSrcAttribsWORD;pszDestFileAnsiChar;dwDestAttribsWORD):UINT;stdcall;
var
Msg:string;
MessType:TMsgDlgType;
begin
Application.Handle:=Hwnd;
Msg:='';
MessType:=mtconfirmation;
case wFunc of
FO_COPY:
begin
Msg:=Format('Are yopu sure you want to copy the %s'+'folder to the %s destination ',[PszSrcFile,pszDestFile]);
end;
FO_DELETE:
begin
Msg:=Format('Are yopu sure you want to del the %s',[PszSrcFile,pszDestFile]);
end;
end;
if msg<>'' then
result:=messageDlg(Msg,MessType,mbYesNoCancel,0 )
else
result:=id_Yes;
end;
initialization
TComObjectFactory.Create(comserver,TPasCopyHook,CLSID_PascalcopHook,'PasalCopyHook','CopyHook Demo from Mastering Delphi 3',ciMultiInstance);
end.
[Error] Unit1.pas(17): Declaration of 'CopyCallback' differs from declaration in interface 'ICopyHookA'
请那为给个答案 谢了
library Project2;
uses
ComServ,
Unit1 in 'Unit1.pas';
exports
DllGetClassObject,
DllCanUnloadNow,
DllRegisterServer,
DllUnregisterServer;
{$R *.RES}
begin
end.
unit Unit1;
interface
uses
Windows,Messages,ComObj,ComServ,SysUtils,Classes,Graphics,Controls,Forms,Dialogs,shellapi,shlobj,ActiveX;
const
CLSID_PascalcopHook:TGUID='{80A06FA0-7df2-11D0-98D0-444553540000}';
type
TpasCopyHooK=class(TComObject,ICopyHook)
public
function CopyCallback(Hwnd:THandle;wFunc,
wFlags:UINT;pszSrcFileAnsiChar;dwSrcAttribsWORD;
pszDestFileAnsiChar;dwDestAttribsWORD):UINT;stdcall;
end;
type
ICopyHookA=interface(IUnKnown)
function CopyCallback(Wnd:Hwnd;wFunc,
wFlags:UINT;pszSrcFileAnsiChar;dwSrcAttribsWORD;
pszDestFileAnsiChar;dwDestAttribsWORD):UINT;
end;
ICopyHook=ICopyHookA;
implementation
function TpasCopyHooK.CopyCallback(Hwnd:THandle;wFunc,wFlags:UINT;pszSrcFileAnsiChar;dwSrcAttribsWORD;pszDestFileAnsiChar;dwDestAttribsWORD):UINT;stdcall;
var
Msg:string;
MessType:TMsgDlgType;
begin
Application.Handle:=Hwnd;
Msg:='';
MessType:=mtconfirmation;
case wFunc of
FO_COPY:
begin
Msg:=Format('Are yopu sure you want to copy the %s'+'folder to the %s destination ',[PszSrcFile,pszDestFile]);
end;
FO_DELETE:
begin
Msg:=Format('Are yopu sure you want to del the %s',[PszSrcFile,pszDestFile]);
end;
end;
if msg<>'' then
result:=messageDlg(Msg,MessType,mbYesNoCancel,0 )
else
result:=id_Yes;
end;
initialization
TComObjectFactory.Create(comserver,TPasCopyHook,CLSID_PascalcopHook,'PasalCopyHook','CopyHook Demo from Mastering Delphi 3',ciMultiInstance);
end.