通过Windows的消息,在局域网内可以给另一台计算机发消息。可以通过Windows API
NetMessageBufferSend函数进行消息发送/
    但Windows的消息不能保存,我想将别人发来的Windows消息进行保留,应该如何捕捉这样的信息?

解决方案 »

  1.   

    to birth_chen(流星):
        用Hook? 是什么意思,能说清楚些吗? 有没有例子代码 ?
      

  2.   

    在过程和函数的后面加message wm_copy;来进行获取呀
      

  3.   

    unit FTSubCls;uses
    SysUtils, WinTypes, WinProcs, Messages, Classes, Controls, Forms;type
      TFTSubclassWnd = class(TComponent)
      private
        FNewWndProcPtr : TFarProc;
        FOldWndProcPtr : TFarProc;
        FWindowHandle : HWnd;
      protected
        { Virtual methods for descendants }
        procedure NewWndProc(var Message: TMessage); virtual; abstract;
        procedure AssignHandle; virtual;
        { Component methods }
        procedure ReplaceWndProc;
        procedure RestoreWndProc;
        procedure CallOldWndProc(var Message: TMessage);
        { Protected properties }
        property NewWndProcPtr: TFarProc read FNewWndProcPtr;
        property OldWndProcPtr: TFarProc read FOldWndProcPtr;
        property WindowHandle: HWnd read FWindowHandle;
      public
        { Construction/destruction }
        constructor Create(AOwner: TComponent); override;
        destructor Destroy; override;
      end;implementationconstructor TFTSubclassWnd.Create(AOwner: TComponent);
    begin
      inherited Create(AOwner);
      if not (AOwner is TForm) then 
        raise Exception.Create('Owner must be form');
      AssignHandle;
      ReplaceWndProc;
    end;destructor TFTSubclassWnd.Destroy;
    begin
      RestoreWndProc;
      inherited Destroy;
    end;procedure TFTSubclassWnd.CallOldWndProc(var Message: TMessage);
    begin
      with Message do
        Result := CallWindowProc(FOldWndProcPtr, FWindowHandle, Msg, wParam, lParam);
    end;procedure TFTSubclassWnd.AssignHandle;
    begin
      with (Owner as TForm) do begin
        HandleNeeded;
        if (FormStyle = fsMDIForm) then 
          FWindowHandle := ClientHandle
        else 
          FWindowHandle := Handle;
      end;
    end;procedure TFTSubclassWnd.ReplaceWndProc;
    begin
      FOldWndProcPtr := Pointer(GetWindowLong(FWindowHandle, GWL_WNDPROC));
      FNewWndProcPtr := MakeObjectInstance(NewWndProc);
      if (FNewWndProcPtr = nil) then
        raise EOutOfResources.Create('Cannot allocate WndProc handle');
      SetWindowLong(FWindowHandle, GWL_WNDPROC, LongInt(FNewWndProcPtr));
    end;procedure TFTSubclassWnd.RestoreWndProc;
    begin
      SetWindowLong(FWindowHandle, GWL_WNDPROC, LongInt(FOldWndProcPtr));
      if FNewWndProcPtr <> nil then 
        FreeObjectInstance(FNewWndProcPtr);
    end;