会员: 密码:  免费注册 | 忘记密码 | 会员登录 网页功能: 加入收藏 设为首页 网站搜索  
 安全技术技术文档
  · 安全配制
  · 工具介绍
  · 黑客教学
  · 防火墙
  · 漏洞分析
  · 破解专题
  · 黑客编程
  · 入侵检测
 安全技术论坛
  · 安全配制
  · 工具介绍
  · 防火墙
  · 黑客入侵
  · 漏洞检测
  · 破解方法
  · 杀毒专区
 安全技术工具下载
  · 扫描工具
  · 攻击程序
  · 后门木马
  · 拒绝服务
  · 口令破解
  · 代理程序
  · 防火墙
  · 加密解密
  · 入侵检测
  · 攻防演示
技术文档 > Delphi
实现Net send命令
发表日期:2003-05-28 00:00:00作者: 出处:  

implement net send?

主要是要向局域网内的机器发送信息。

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;

返回顶部】 【打印本页】 【关闭窗口

关于我们 / 给我留言 / 版权举报 / 意见建议 / 网站编程QQ群   
Copyright ©2003- 2024 Lihuasoft.net webmaster(at)lihuasoft.net 加载时间 0.00186