• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

delphi怎么ping计算机名或ip地址

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
delphi 怎么ping计算机名或ip 地址 Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiNetwork/html/delphi_20061201140126219.html
delphi   怎么ping计算机名或ip   地址???

indy   idICMP

function   TMainForm.ping(   var   url:   string):boolean;     var  
      aIdICMPClient:   TIdICMPClient;  
  begin  
      aIdICMPClient:=   TIdICMPClient.Create(nil);  
      aIdIcmpclient.ReceiveTimeout:=500;                  
      aIdICMPClient.Host:=   url;  
      try  
          aIdICMPClient.Ping();  
      except  
          Result:=   False;  
      end;  
      if   (aidicmpclient.ReplyStatus.fromipaddress<>'0.0.0.0')  
            and   (aidicmpclient.ReplyStatus.fromipaddress<>'')   then  
          result:=true  
      else  
          result:=false;  
      aIdICMPClient.Free;  
  end;  
   
   
  我这里能ping   通ip地址,但是ping   不通计算机名?  
  为何

在“CMD”里面Ping一下看  
  另外,如果操作系统是XP,有时是Ping机器名时是Ping不到的

在HOSTs文件里面加一条就可以了:(XP:   C:\WINDOWS\system32\drivers\etc目录下)  
   
  #   Copyright   (c)   1993-1999   Microsoft   Corp.  
  #  
  #   This   is   a   sample   HOSTS   file   used   by   Microsoft   TCP/IP   for   Windows.  
  #  
  #   This   file   contains   the   mappings   of   IP   addresses   to   host   names.   Each  
  #   entry   should   be   kept   on   an   individual   line.   The   IP   address   should  
  #   be   placed   in   the   first   column   followed   by   the   corresponding   host   name.  
  #   The   IP   address   and   the   host   name   should   be   separated   by   at   least   one  
  #   space.  
  #  
  #   Additionally,   comments   (such   as   these)   may   be   inserted   on   individual  
  #   lines   or   following   the   machine   name   denoted   by   a   '#'   symbol.  
  #  
  #   For   example:  
  #  
  #             102.54.94.97           rhino.acme.com                     #   source   server  
  #               38.25.63.10           x.acme.com                             #   x   client   host  
   
  127.0.0.1               localhost  
  #把你的IP和HOST按下面格式输入  
  200.211.110.133   SANMAOTUO

如果加上楼上说的.肯定是可以通的.  
  但是局域网内丑那么多电脑.我不可能没一台都去改一下hosts文件吧  
  .好像是dns的问题.  
   
  我本来想用api把名字解悉为ip,但是如果不在hosts里面加的话。解析不出来。  
  有没有别的办法啊。。  
  高手们,帮帮我把

路过


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
初识Delphi【原创+转载】发布时间:2022-07-18
下一篇:
DelphiTreeView设置树全部展开发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap