上一个程序在收到后能根据选择将消息发到指定得地方,一般来说是记事本或者Word等,
现在,给你一个简化的:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
n,curhandle:integer;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
var
hCurWindow: HWnd; // 窗口句柄
name:string;
txtlen:integer;
begin
hCurWindow := FindWindow ('#32770','信使服务 '); //注意后面有一个空格!
n:=hCurWindow ;
if (n <> 0) and (n <> curhandle ) then
begin
Timer1 .Enabled :=false;
curhandle :=n;
hCurWindow :=FindWindowEX(hCurWindow ,0,'static',nil);
TxtLen:=sendmessage(hCurWindow ,wm_gettextlength,0,0)+1;
setlength(name,TxtLen);
sendmessage(hCurWindow ,wm_gettext,txtlen,LongInt(@name[1]));
ShowMessage(string(name));
Timer1 .Enabled :=true;
end;
end;
end.
应该没有问题了:)