声明
var
  EventArr:array[0..1000] of EVENTMSG;钩子函数
function HookProc(iCode:Integer;wParam:WPARAM;lParam:LPARAM):LRESULT;stdcall;  //记录操作
begin
  recOK:=1;
  Result:=0;
  if iCode < 0 then
    Result:=CallNextHookEx(hHook,iCode,wParam,lParam)
  else if iCode = HC_SYSMODALON then
    recOK:=0
  else if iCode = HC_SYSMODALOFF then
    recOK:=1
  else if ((recOK>0) and (iCode = HC_ACTION)) then
    begin
      EventArr[EventLog]:=PEventMSG(lParam)^;
      EventLog:=EventLog+1;
      if EventLog >=1000 then
        begin
          UnhookWindowsHookEx(hHook)
        end;
    end;
end;现在我想显示记录
 for i:=0 to Low(EventArr) do
   begin
     str:=str+EventArr[i];
   end;
   MessageBox(self.Handle,PChar(str),'系统提示',MB_ICONINFORMATION);但提示:
[Error] uServer.pas(196): Incompatible types: 'String' and 'tagEVENTMSG'错误
该如何转换呀请高手帮帮忙

解决方案 »

  1.   

    tagEVENTMSG = packed record
        message: UINT;
        paramL: UINT;
        paramH: UINT;
        time: DWORD;
        hwnd: HWND;
      end;结构是这样,你需要哪个数据就用IntToStr来转换
      

  2.   

    多谢 liangqingzhi(老之) 
    我把它改成这样子的,就可以编译了 for i:=0 to Low(EventArr) do
               begin
                 str:=str+inttostr(EventArr[i].message)+' '+ inttostr(EventArr[i].paramL)
                      +' '+inttostr(EventArr[i].paramH)+' '+ inttostr(EventArr[i].time)
                      +' '+inttostr(EventArr[i].hwnd);
               end;但是结果根本不是键盘输入的值呀请问是怎么回事昵