Delph i判断IP地址是否正确


本文整理自网络,侵删。

 function IsValidIP(strIP: string): Boolean;
var
  i, PartCount {用多少段,以点号分开}: Integer;
  Part: string;
begin
  PartCount :0;
  while strIP <> '' do
  begin
    i := Pos('.', strIP);
    if i = 0 then
    begin
      Part := strIP;
      strIP :'';
    end
    else
    begin
      Part := Copy(strIP, 1, i - 1);
      Delete(strIP, 1, i);
    end;
    //IP分段必须是[0,255]的整数
    if not TryStrToInt(Part, i) or (i < 0or (i > 255then
    begin
      Result := False;
      Exit;
    end;
    Inc(PartCount);
  end;
  Result := PartCount = 4//必须要有4
end;

相关阅读 >>

Delphi之猥琐的webserver实现

Delphi 实现如何枚举所有打开的ie选项卡

Delphi判断ie是否使用代理

Delphi opentextfiledialog用法

Delphi firedac fdconnection 事务

Delphi extractfileext() 获取文件后缀的函数

Delphi speedbutton按钮动态加载图片(从image和imagelist)

Delphi tadoquery 中文使用说明

Delphi流的操作

Delphi中使用xmlhttp / xmlhttprequest 避免缓存

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...

    暂无评论...