有时候注入到一个窗体进程内,需要同时响应窗体内的消息时候,我们可以这样做
1、写个自己处理消息的例程
Function WndProc(Hwnd,Msg,wParam,lParam:longint):LRESULT; stdcall;
begin
case Msg of
WM_KEYDOWN: begin
//处理消息
end;
end;
//继续向下传递
Result:=CallWindowProc(OldProc,Hwnd,Msg,wParam,lParam);
end;
2、将自己的例程插入到窗体消息队列中
var
OldProc:FARPROC;
begin
OldProc:=FARPROC(GetWindowLong(窗体的句柄,GWL_WNDPROC));
SetWindowLong(窗体的句柄,GWL_WNDPROC,Longint(@WndProc));
end;