请问如何用delphi实现net send一样的功能(在线等待,急) (200分)

  • 主题发起人 主题发起人 lycok
  • 开始时间 开始时间
L

lycok

Unregistered / Unconfirmed
GUEST, unregistred user!
在局域网中我想给某台电脑发消息,用net send 可以实现,但是我如果用delphi编程如何实现呢?
有没有现成的API函数可以调用?或者用什么控件?
局域网中用的都是wingdows2000
 
我有C的,需要给我发邮件tseug@263.net
Delphi 参考
http://djernaes.dk/martin/winpopup.html
http://www.torry.net/lan_comms.htm
 
有这方面的Delphi控件,需要的话给我邮件:xzuse@szonline.net
 
很简单的,只要利用一下系统的netapi32即可!
下面是代码
function NetMessageBufferSend; external 'netapi32.dll' name 'NetMessageBufferSend';

function SendMsg(Toh,From,Msg:string):integer;
//toh 目标机器IP地址
//From 源地址,可以为空
//Msg 要发的信息
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;
 
to only you:
你好,我采用了你的程序,可是编译不通过,报错“无法定位程序输入点NetmessageBufferSend与动态链接库netapi32.dll上”
请问这是怎么回事儿?你能帮我看看程序吗?

unit Unit2;

interface
uses SysUtils,Classes;

function ToUnicode(str:string;dest:PWideChar):integer;
function SendMsg(Toh,From,Msg:string):integer;
function NetMessageBufferSend(servername:PWideChar;
MsgName:PWideChar;
Buf:PWideChar;
var BufLen:integer):integer;cdecl;

implementation

function ToUnicode(str:string;dest:PWideChar):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;
WMsgText:array[0..1000] of WideChar;
MsgLen,i:integer;
begin
//MsgLen:=255;
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,@WMsgText,MsgLen);
end;

end.
 
unit MsgSend;

interface
uses sysutils,classes,Unit1;


function A(str:string;dest:PWideChar):integer; //将ASCII码转为Uncodes码
Function SendMsg(Toh,From,Msg:string):integer;
Function NetMessageBufferSend(ServerName:pointer;MsgName:pointer;FromName:pointer;Buf:pointer;var BufLen:integer):integer;cdecl;
implementation

function A(str:string;dest:PWideChar):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.
 
//不会吧.没问题啊
unit netSendMsg;
interface
uses SysUtils, Classes;

function ToUnicode(str:string;dest:PWideChar):integer;
function SendMsg(Toh,From,Msg:string):integer;
function NetMessageBufferSend(servername:PWideChar;
MsgName:PWideChar;
FromName:PWideChar;
Buf: PWideChar;
var BufLen:integer):integer;cdecl;
implementation
function ToUnicode(str:string;dest:PWideChar):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;
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;

end.
 
谢谢,原来如此!!散分啦
 
后退
顶部