1 遍历IP
代码
// 参数为网络字节序
// 如 192.0.0.1 (1<<24)+(0<<16)+(168<<8)+(192<<1) = 16820416; API inet_addr('192.0.0.1')
procedure EnumiP(LowIp, HighIp: DWORD; var AStr: TStrings);
var
I: DWORD;
begin
for I := htonl(LowIp) to htonl(HighIp) do
AStr.Add(inet_ntoa(TInAddr(htonl(I))));
end;
// 如 192.0.0.1 (1<<24)+(0<<16)+(168<<8)+(192<<1) = 16820416; API inet_addr('192.0.0.1')
procedure EnumiP(LowIp, HighIp: DWORD; var AStr: TStrings);
var
I: DWORD;
begin
for I := htonl(LowIp) to htonl(HighIp) do
AStr.Add(inet_ntoa(TInAddr(htonl(I))));
end;