delphi 得到IP三个值


本文整理自网络,侵删。

 


function GetIP1(const S: String): String; //192.168.1.1  得到 192
var
tempstr:string;
begin
tempstr:=SplitString(S,'.').Strings[0];
tempstr:=StringReplace (tempstr, '.', '', []);
result :=tempstr;
end;

function GetIP2(const S: String): String;//192.168.1.1  得到 168
var
tempstr:string;
begin
tempstr:=SplitString(S,'.').Strings[1];
tempstr:=StringReplace (tempstr, '.', '', []);
result :=tempstr;
end;

function GetIP3(const S: String): String;//192.168.1.1  得到 1
var
tempstr:string;
begin
tempstr:=SplitString(S,'.').Strings[2];
tempstr:=StringReplace (tempstr, '.', '', []);
result :=tempstr;
end;

function SplitString(const Source,ch:String):TStringList;
var
temp:String;
i:Integer;
begin
Result:=TStringList.Create;
//如果是空自符串则返回空列表
if Source=''
then exit;
temp:=Source;
i:=pos(ch,Source);
while i<>0 do
begin
Result.add(copy(temp,0,i-1));
Delete(temp,1,i);
i:=pos(ch,temp);
end;
Result.add(temp);
end;

相关阅读 >>

Delphi idhttp代理设置

Delphi中窗体的方法

apk权限大全 android必懂知识

Delphi获得系统当前时间日期和格式化时间

Delphi发送邮件函数

Delphi apihook createprocess

Delphi2010读取mysql数据库text类型乱码的解决方案

进程防杀Delphi版(dll部分)

Delphi json字符串转义

Delphi 从dbgird中导出到excel

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



打赏

取消

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

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

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

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

评论

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