我要做一个管理机房管理软件,要用这个,哪位帮忙呀

解决方案 »

  1.   

    多thanks凤凰老兄?
    这个是解决了,另外一个问题??
    在Windows中做了个线程hook回放操作记录?
    现在有一个问题是,
      能不能把这个记录保存成文件,然后在其它地方回放
      

  2.   

    Windows 的SetWindowshookex()这个含数吗,也是从网上找的源代码?要不你看一下Function PlayProc(iCode:Integer;wParam:wParam;lParam:lParam):LRESULT;stdcall;
    begin
      canPlay:=1;
      Result:=0;  if iCode < 0 then     //必须将消息传递到消息链的下一个接受单元
        Result := CallNextHookEx(hPlay,iCode,wParam,lParam)
      else if iCode = HC_SYSMODALON then
      canPlay:=0
      else if iCode = HC_SYSMODALOFF then
        canPlay:=1
      else if ((canPlay =1 )and(iCode=HC_GETNEXT)) then begin
        if bDelay then begin
          bDelay:=False;
          Result:=50;
        end;
        pEventMSG(lParam)^:=EventArr[PlayLog];
      end
      else if ((canPlay = 1)and(iCode = HC_SKIP))then begin
        bDelay := True;
        PlayLog:=PlayLog+1;
      end;
      if PlayLog>=EventLog then begin
        UNHookWindowsHookEx(hPlay);
      end;
    end;
    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;procedure TForm1.FormCreate(Sender: TObject);
    begin
       Button1.Caption:='纪录';
      Button2.Caption:='停止';
       Button3.Caption:='回放';
      Button4.Caption:='范例';
      Button2.Enabled:=False;
      Button3.Enabled:=False;end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      EventLog:=0;
      //建立键盘鼠标操作消息纪录链
      hHook:=SetwindowsHookEx(WH_JOURNALRECORD,HookProc,HInstance,0);
      Button2.Enabled:=True;
      Button1.Enabled:=False;end;procedure TForm1.Button2Click(Sender: TObject);
    begin
      UnHookWindowsHookEx(hHook);
      hHook:=0;  Button1.Enabled:=True;
      Button2.Enabled:=False;
      Button3.Enabled:=True;end;procedure TForm1.Button3Click(Sender: TObject);
    begin
      PlayLog:=0;
      //建立键盘鼠标操作消息纪录回放链
      hPlay:=SetwindowsHookEx(WH_JOURNALPLAYBACK,PlayProc,
        HInstance,0);