I want to write Global Hook. As an application, the code below works. But not as a service.
function TrapKeyboardInput(nCode: integer; wp: wParam; lp: lParam): LResult; stdcall;
// Windows Hook Procedure To Intercept Keyboard Input
begin
// This Structure is Defined By The Windows API
if nCode < 0 then
Result := CallNextHookEx(hook_Keyboard, nCode, wp, lp)
else
begin
if nCode = HC_ACTION then
begin
SecondInactionHO := 0;
Result := 0;
end
else
Result := 0;
end;
end;
procedure StartHock();
begin
hook_Keyboard := SetWindowsHookEx(WH_KEYBOARD_LL, @TrapKeyboardInput, HInstance, 0);
end;