unit MsgSend;
interface
uses sysutils,classes,Unit1;
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 A(str:string;dest
WideChar):integer;
var
len:integer;
begin
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.