CnPack Forum


 
Subject: TCnIp可以获取本机IP列表吗?
sibad_sh
新警察
Rank: 1



UID 41291
Digest Posts 0
Credits 26
Posts 9
点点分 26
Reading Access 10
Registered 2008-11-17
Status Offline
Post at 2009-3-31 16:31  Profile | Blog | P.M. 
TCnIp可以获取本机IP列表吗?

Ip: TCnIp;
.....


Ip.IPAddress;可以获取到本机一个ip

IP.LocalIPCount;可以获取到本机有几个IP

怎么获取本机其他的IP?
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2009-3-31 23:42  Profile | Blog | P.M. 
先移动到CnPack组件包版了。
Top
sibad_sh
新警察
Rank: 1



UID 41291
Digest Posts 0
Credits 26
Posts 9
点点分 26
Reading Access 10
Registered 2008-11-17
Status Offline
Post at 2009-4-1 19:29  Profile | Blog | P.M. 
Passion: 帮我下忙,告诉我怎么获取其他IP?
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2009-4-8 07:30  Profile | Blog | P.M. 
LocalIPGroup这个动态数组就是。
Top
kmchen
新警察
Rank: 1



UID 42167
Digest Posts 0
Credits 12
Posts 4
点点分 12
Reading Access 10
Registered 2009-4-10
Status Offline
Post at 2009-4-10 00:18  Profile | Blog | P.M. 
cnip报错。

scnipname,scnpack_sesame等几个变量没有定义,是不是我没引用什么单元呀。第一次用cnpack组件,请多多原谅。谢谢。
Top
sibad_sh
新警察
Rank: 1



UID 41291
Digest Posts 0
Credits 26
Posts 9
点点分 26
Reading Access 10
Registered 2008-11-17
Status Offline
Post at 2009-4-11 16:59  Profile | Blog | P.M. 
IP := TCnIp.Create(nil);
  try
    for I := 0 to IP.LocalIPCount -1 do
    begin
      addr.S_addr := IP.LocalIPGroup[I].IPAddress;
      Memo.Lines.Add(String(inet_ntoa(addr)));
    end;
  finally
    FreeAndNil(IP);
  end;

显示反过来了?
20.1.168.192

该不是还要转换吧
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2009-4-11 21:31  Profile | Blog | P.M. 
烦请使用IP.IntToIP(IP.LocalIPGroup[I].IPAddress);

也就是其方法:
    function IntToIP(const aIP: Cardinal): string;
    {* 转换整数为IP地址}
来进行转换。
Top
sibad_sh
新警察
Rank: 1



UID 41291
Digest Posts 0
Credits 26
Posts 9
点点分 26
Reading Access 10
Registered 2008-11-17
Status Offline
Post at 2009-4-20 10:38  Profile | Blog | P.M. 
谢谢Passion
Top
 




All times are GMT++8, the time now is 2024-11-22 06:28

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.008358 second(s), 7 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP