delphi里听说可以利用NetMessageBufferSend发局域网内的用户消息,
那怎么接收消息???????

解决方案 »

  1.   

    要想接收该消息,只要打开系统messendger服务就可以接收。如果想在自己的程序里接收该消息,需要使用Hook,Hook所有的弹出窗体,根据弹出窗体的标题进行判断。然后获取里面的内容,再将窗体关闭。
      

  2.   

    楼上的怎么搞呢????unit Unit1;
    interface
    uses
     Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls;
    type
     NET_API_STATUS = LongInt;
     function NetMessageBufferSend(servername: LPCWSTR; msgname: LPCWSTR;
     fromname: LPCWSTR; buf: Pointer;
     buflen: DWORD): NET_API_STATUS;
     stdcall;external 'netapi32.dll';
    type
     TForm1 = class(TForm)
     Edit1: TEdit;
     Label1: TLabel;
     Label2: TLabel;
     Edit2: TEdit;
     Button1: TButton;
     procedure Button1Click(Sender: TObject);
    private
     { Private declarations }
    public
    { Public declarations }
    end;
    var
     Form1: TForm1;
     implementation
     {$R *.dfm}
     procedure TForm1.Button1Click(Sender: TObject);
    var
     WideMsg:PWideChar;
     DestName:PWideChar;
    begin
     DestName:=PWideChar(WideString(Edit1.Text));
     WideMsg:=PWideChar(WideString(Edit2.Text));
     NetMessageBufferSend(nil,DestName,nil,WideMsg,Length(Edit2.Text)*2);
    end;
    end. 这段代码 编译不过去 我有把那个dll文件放在该工程目录下编译错误提示什么  非法字符之类 的再问一下,怎么Hook,自己才能收到消息???????
      

  3.   

    "非法字符之类",你是从网上COPY下来的吧?代码中有中文字符,可能你没看到,你把代码自己重新输入一遍,肯定可以编译通过的。Hook所有的窗口创建,发现有标题为"信使服务 "的窗口,获取其中的Static中的内容就是消息内容。如果你还不懂的话,你上网搜索吧。这个问题不是一两句就可以说的清楚的。