消息发送一般是包装dos命令,如下
winexec(pchar('net send '+host+' '+ content),sw_hide); //1
winexec(pchar('command.com /c net send '+host+' '+ content),sw_hide); //2
//2。加上 command.com /c 只能发送单行文本。
//////////////////////
function NetMessageBufferSend(servername
WideChar;
MsgName
WideChar;
FromName
WideChar;
Buf: PWideChar;
var BufLen:integer):integer; stdcall;
external 'netapi32.dll';
function ToUnicode(str:string;dest
WideChar):integer;
function SendMsg(Toh,From,Msg:string):integer;
var
Form1: TForm1;
implementation
{$R *.dfm}
function ToUnicode(str:string;dest
WideChar):integer;
var
len:integer;
begin
StringToWideChar(str,dest,len);
Result:=len;
end;
function SendMsg(Toh,From,Msg:string):integer;
var
ToName :array [0..64] of WideChar;
WMsgText:array [0..1000] of WideChar;
MsgLen, i:integer;
begin
for i := 0 to 64 do ToName
:= #0;
ToUnicode(Toh,ToName);
for i := 0 to 1000 do WMsgText := #0;
ToUnicode(Msg,WMsgText);
Result:=NetMessageBufferSend(nil,ToName,nil,@WMsgText,MsgLen);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SendMsg('visio','ww','ss');
end;
///////////////////////