毕业论文

打赏
当前位置: 毕业论文 > 计算机论文 >

茬應用程序中跟踪MOUSE的坐标【113字】

时间:2023-04-11 22:35来源:毕业论文
茬應用程序中跟踪MOUSE的坐标【113字】

第一步,建一DLL,DELPHI中NEW-DLLSAVEASGETKEYlibrarygetKey;uses

SysUtils,

<

第一步,建一DLL,DELPHI中NEW-DLLSAVEASGETKEYlibrarygetKey;uses

SysUtils,

Windows,

HookMaininhookmain。pas;exports

OpenGetKeyHook,论文网>

CloseGetKeyHook,

GetPublicP;begin

NextHook:=0;

procSaveExit:=ExitProc;

DLLproc:=@DLLMain;

ExitProc:=@HookExit;

DLLMain(DLL_PROCESS_ATTACH);

end。第二步,建一UNIT,HOOKMAIN。关键在于CreateFileMapping和消息WM_NCMouseMove,WM_MOUSEMOVE:unitHookMain;interface

usesWindows,Messages,Dialogs,SysUtils;//typeDataBuf=Array[1。。2]ofDWORD;

typemydata=record

data1:array[1。。2]ofDWORD;

data2:TMOUSEHOOKSTRUCT;

end;

varhObject:Thandle;

pMem:Pointer;

NextHook:Hhook;

procSaveExit:Pointer;functionHookHandler(iCode:Integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;export;

functionOpenGetKeyHook(sender:HWND;MessageID:WORD):BOOL;export;

functionCloseGetKeyHook:BOOL;export;

functionGetPublicP:Pointer;stdcall;export;

ProcedureDLLMain(dwReason:Dword);far;

procedureHookExit;far;implementationProcedureUnMapMem;

begin

ifAssigned(pMem)then

begin

UnMapViewOfFile(pMem);

pMem:=Nil

end;

end;ProcedureMapMem;

begin

hObject:=CreateFileMapping($FFFFFFFF,Nil,Page_ReadWrite,0,$FFFF,pChar(_IOBuffer));

ifhObject=0thenRaiseException。Create(创建公用数据的Buffer不成?;

pMem:=MapViewOfFile(hObject,FILE_MAP_WRITE,0,0,SizeOf(mydata));

//1orSizeOf(DataBuf)????

//创建SizeOf(DataBuf)的数据区

ifnotAssigned(pMem)then

begin

UnMapMem;

RaiseException。Create(创建公用数据的映射关系不成功!);

end;

end;

ProcedureDLLMain(dwReason:Dword);far;

begin

CasedwReasonof

DLL_PROCESS_ATTACH:

begin

pMem:=nil;

hObject:=0;

MapMem;//以下的公有数据,如tHWND,tMessageID将直接使用本Buf。

End;

DLL_PROCESS_DETACH:UnMapMem;

DLL_THREAD_ATTACH,

DLL_THREAD_DETACH:;//缺省

end;

end;procedureHookExit;far;

begin

CloseGetKeyHook;

ExitProc:=procSaveExit;

end;functionGetPublicP:Pointer;export;

begin//这里引出了公用数据区的指针,你可以在你的应用程序中自由操作它。但建议去掉此接口。

Result:=pMem;

end;functionHookHandler(iCode:Integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;export;

begin

Result:=0;

IfiCode$#@60;0

ThenResult:=CallNextHookEx(NextHook,iCode,wParam,lParam);

//Thisisprobablyclosertowhatyouwouldwanttodo。。。

Casewparamof

WM_LBUTTONDOWN:

begin

end;

WM_LBUTTONUP:

begin

end;

WM_LBUTTONDBLCLK:

begin

end;

WM_RBUTTONDOWN:

begin

messagebeep(1);

end;

WM_RBUTTONUP:

begin

end;

WM_RBUTTONDBLCLK:

begin

end;

WM_MBUTTONDOWN:

begin

end;

WM_MBUTTONUP:

begin

end;

WM_MBUTTONDBLCLK:

[1][2]下一页

茬應用程序中跟踪MOUSE的坐标【113字】:http://www.youerw.com/jisuanji/lunwen_158431.html
------分隔线----------------------------
推荐内容