一个关于COPYHOOK的测试谁能帮我看一下为什么不起作用(100分)

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

lsc0530

Unregistered / Unconfirmed
GUEST, unregistred user!
我的.reg文件是
REGEDIT4

[HKEY_CLASSES_ROOT/CLSID{/80A06FA0-7DF2-11D0-98D0-444553540000}]
@="PascalCopyHooK"
[HKEY_CLASSES_ROOT/CLSID/{80A06FA0-7DF2-11D0-98D0-444553540000}/InprocServer32]
@="d:aa.dll"
"ThreadingModel"="Apartment"

[HKEY_CLASSES_ROOT/Directory/shellex/CopyHookHandlers/PCopyHooK]
@="{80A06FA0-7DF2-11D0-98D0-444553540000}"



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
ICopyHookA=interface(IUnKnown)
function CopyCallback(Hwnd:THandle;wFunc,
wFlags:UINT;pszSrcFile:PAnsiChar;dwSrcAttribs:DWORD;
pszDestFile:PAnsiChar;dwDestAttribs:DWORD):UINT;
end;
ICopyHook=ICopyHookA
type
TpasCopyHooK=class(TComObject,ICopyHook)
public
function CopyCallback(Hwnd:THandle;wFunc,
wFlags:UINT;pszSrcFile:PAnsiChar;dwSrcAttribs:DWORD;
pszDestFile:PAnsiChar;dwDestAttribs:DWORD):UINT;stdcall;
end;

implementation
function TpasCopyHooK.CopyCallback(Hwnd:THandle;wFunc,wFlags:UINT;pszSrcFile:PAnsiChar;dwSrcAttribs:DWORD;pszDestFile:PAnsiChar;dwDestAttribs:DWORD):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.
 
后退
顶部