📄 demohook.dpr
字号:
library DemoHook;
uses
windows,messages,sysutils;
type
TWin = record
Msg:TMsg;
wClass:TWndClass;
hMain:integer;
hLib:integer;
end;
var
Win:TWin; //结构变量
// WorkPath:string;
HMouse:HHook;
start:boolean;
hrun:procedure;
Count,tid,hInfo:integer;
//
function DeThreadHook:boolean;stdcall;
begin
result:=UnhookWindowsHookEx(HMouse);
hInfo:=findwindow('HookHost',nil);
if hInfo<>0 then
begin
if result=true then postmessage(findwindow('HookHost',nil),wm_command,2,1)
else postmessage(findwindow('HookHost',nil),wm_command,2,0);
end;
end;
//
function MouseProc(nCode:integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;
begin
hInfo:=findwindow('HookHost',nil);
if hInfo<>0 then
begin
postmessage(hInfo,wm_command,3,count);
postmessage(hInfo,wm_command,$11,GetCurrentProcessId);
postmessage(hInfo,wm_command,$21,GetCurrentThreadId);
end;
inc(count);
if start=true then
begin
win.hlib:=loadlibrary(pchar('c:\Delphi2\HookThread\RServer.dll'));
hrun:=GetProcAddress(win.hlib,'run');
if @hrun<>nil then hrun;
end;
start:=false;
Result:=CallNextHookEx(0,nCode,wParam,lParam);
end;
procedure SetThreadHook;stdcall;
begin
tid:=GetWindowThreadProcessId(findwindow('ProgMan',nil),nil);
HMouse:=SetWindowsHookEx(WH_MOUSE,@MouseProc,hinstance,tid);
hInfo:=findwindow('HookHost',nil);
if hInfo<>0 then
begin
if hmouse=0 then postmessage(findwindow('HookHost',nil),wm_command,1,0)
else postmessage(findwindow('HookHost',nil),wm_command,1,1);
end;
end;
//
exports SetThreadHook,DeThreadHook;
begin
start:=true;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -