在不使用客户端程序的情况下,实现向客户端发送信息(100分) (100分)

  • 主题发起人 主题发起人 hjchen_tx
  • 开始时间 开始时间
H

hjchen_tx

Unregistered / Unconfirmed
GUEST, unregistred user!
管理员端为WIN2000,客户端未知
如何在不使用客户端程序的情况下向客户端发送信息?
 
可以调用系统服务,只要知道IP和端口就可以
 
谢谢关注! IP地址已知.怎样通过编程实现?
 
事情是这样的.在局域网内,有好几个段,但老是有人改IP地址,无法控制.
我已经实现了用MAC和IP对应的方法来实时监测对应于同一个MAC的IP地址的变化
但无法向这个MAC地址发送警告信息,因为不允许安装客户端.所以向各位高手请教.
 
http://www.delphibbs.com/delphibbs/dispq.asp?lid=1740406
 
我从网上找到一些资料并事理后做了一个小程序可以实现本功能,但是只能在WIN2000
下用在WIN98下用不了,如果有好的方法能实现本功能敬请指教代码如下:
主要是要向局域网内的机器发送信息(本代码从网上得到)。
function NetSend(dest, Source, Msg: string): Longint; overload;
type
TNetMessageBufferSendFunction = function(servername, msgname, fromname: PWideChar;
buf: PWideChar; buflen: Cardinal): Longint;
stdcall;
var
NetMessageBufferSend: TNetMessageBufferSendFunction;
SourceWideChar: PWideChar;
DestWideChar: PWideChar;
MessagetextWideChar: PWideChar;
Handle: THandle;
begin
Handle := LoadLibrary('NETAPI32.DLL');
if Handle = 0 then
begin
Result := GetLastError;
Exit;
end;
@NetMessageBufferSend := GetProcAddress(Handle, 'NetMessageBufferSend');
if @NetMessageBufferSend = nil then
begin
Result := GetLastError;
Exit;
end;
MessagetextWideChar := nil;
SourceWideChar := nil;
DestWideChar := nil;
try
GetMem(MessagetextWideChar, Length(Msg) * SizeOf(WideChar) + 1);
GetMem(DestWideChar, 20 * SizeOf(WideChar) + 1);
StringToWideChar(Msg, MessagetextWideChar, Length(Msg) * SizeOf(WideChar) + 1);
StringToWideChar(Dest, DestWideChar, 20 * SizeOf(WideChar) + 1);
if Source = '' then
Result := NetMessageBufferSend(nil, DestWideChar, nil,
MessagetextWideChar, Length(Msg) * SizeOf(WideChar) + 1)
else
begin
GetMem(SourceWideChar, 20 * SizeOf(WideChar) + 1);
StringToWideChar(Source, SourceWideChar, 20 * SizeOf(WideChar) + 1);
Result := NetMessageBufferSend(nil, DestWideChar, SourceWideChar,
MessagetextWideChar, Length(Msg) * SizeOf(WideChar) + 1);
FreeMem(SourceWideChar);
end;
finally
FreeMem(MessagetextWideChar);
FreeLibrary(Handle);
end;
end;
function NetSend(Dest, Msg: string): Longint; overload;
begin
Result := NetSend(Dest, '', Msg);
end;
function NetSend(Msg: string): Longint; overload;
begin
Result := NetSend('', '', Msg);
end;
// Example:使用例子
procedure TForm1.Button1Click(Sender: TObject);
const
NERR_BASE = 2100;
NERR_NameNotFound = NERR_BASE + 173;
NERR_NetworkError = NERR_BASE + 36;
NERR_Success = 0;
var
Res: Longint;
sMsg: string;
begin
Res := NetSend('LoginName', 'Your Message...');
case Res of
ERROR_ACCESS_DENIED: sMsg := 'user does not have access to the requested information.';
ERROR_INVALID_PARAMETER: sMsg := 'The specified parameter is invalid.';
ERROR_NOT_SUPPORTED: sMsg := 'This network request is not supported.';
NERR_NameNotFound: sMsg := 'The user name could not be found.';
NERR_NetworkError: sMsg := 'A general failure occurred in the network hardware.';
NERR_Success: sMsg := 'Message sent!';
end;
ShowMessage(sMsg);
end;
代码:
[:)]
 
谢谢大家,看来在WIN98下是实现不了了!
 
后退
顶部