这是我写的
unit UnitMsg;
interface
Uses Windows,Messages;
function A(str:string;dest
WideChar):integer; //将ASCII码转为Uncodes码
Function SendMsg(Toh,From,Msg:string):integer;
Function NetMessageBufferSend(ServerName
ointer;MsgName
ointer;FromName
ointer;Buf
ointer;var BufLen:integer):integer;cdecl;
implementation
function GetNTMsg(): Pchar; stdcall;
var
ParenthWnd,hWnd: LongInt;
msg: pchar;
begin
Result:='';
getmem(msg, 255);
ParenthWnd := FindWindow(nil, '信使服务 ');
if hWnd <> 0 then
begin
hwnd := findwindowex(ParenthWnd, 0, 'Static', nil);
getwindowtext(hwnd, msg, 255);
result := msg;
PostMessage(ParenthWnd,WM_Close,0,0);
end;
end;
function A(str:string;dest
WideChar):integer;
var
len:integer;
begin
//len:=0;
stringtowidechar(str,dest,len);
result:=len;
end;
Function NetMessageBufferSend;external 'netapi32.dll' name 'NetMessageBufferSend';
Function SendMsg(Toh,From,Msg:string):integer;
var
ToName:array[0..64] of widechar; //显示的对方名称
FromName:array[0..64] of widechar; //显示的发送方名称
MsgLen,i:integer;
WMsgText:array[0..1000] of widechar; //发送的消息
begin
for i:=0 to 64 do ToName
:=#0;
A(Toh,ToName);
for i:=0 to 64 do FromName:=#0;
A(From,FromName);
for i:=0 to 1000 do WMsgText:=#0;
A(Msg,WMsgText);
result:=NetMessageBufferSend(nil,@ToName,@FromName,@WMsgText,MsgLen);
end;
end.
然后这样就可以: SendMsg(SendTo,edtSendFrom.text,memoMsg.text);