i tried to hook the function SendMessage from User32 (just to come into contact with the component). If I hook the function and call SendMessage in the same programm it will work. But if I hook the function and send messages in other programms it will not work (no messagebox appears). Here is my code:
Code: Select all
SendMsgNextHook : function (hWnd: HWND; Msg: Cardinal; wParam: Integer; lParam: Integer): integer; stdcall;
function SendMsgHookProc(hWnd: HWND; Msg: Cardinal; wParam: Integer; lParam: Integer): integer; stdcall;
begin
if MessageBox(0, PChar(inttostr(Msg)), 'Execute?', MB_YESNO or MB_ICONQUESTION) = IDYES then
result:= SendMsgNextHook(hWnd, Msg, wParam, lParam)
else
result:= ERROR_ACCESS_DENIED;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
HookAPI('user32.dll', 'SendMessageA', @SendMsgHookProc, @SendMsgNextHook);
SendMessage(Handle,0,0,0) // Works, but not in other programms
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
UnhookAPI(@SendMsgNextHook);
end;
Greetings,
Crocotronic
EDIT: Damn, it's just process wide, right? How to realize it system wide?