Delphi IPNumberIPV4


本文整理自网络,侵删。

 
unit Unit5;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs;

type
  TForm5 = class(TForm)
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form5: TForm5;

implementation

{$R *.dfm}


function GetIPNumberIPV4(ip: string): integer;
var
  List: TStringList;
  A, B, C, D, E, F: integer; //Biginteger...?
  total: string;
begin
  Result := 0;

  if ip = '::1' then
    ip := '127.0.0.1';

  List := TStringList.Create;
  try
    List.Delimiter := '.';
    List.StrictDelimiter := True;
    List.DelimitedText := ip;

    A := strtoint(List[0]);
    B := strtoint(List[1]);
    C := strtoint(List[2]);
    D := strtoint(List[3]);

 ////Result :=  (A shl 40) +  (B shl 32) + (C shl 24) + (D shl 16) + (E shl 8) + F; // BIG INTEGER PROBLEMS..

     Result := (A shl 24) + (B shl 16) + (C shl 8) + D;
  finally
    List.Free;
  end;
end;




procedure TForm5.FormCreate(Sender: TObject);
begin
text:=IntToStr(GetIPNumberIPV4('127.0.0.1'));
end;

end.

相关阅读 >>

Delphi-改进获取文件md5 hash方法

Delphi 得到文件创建时间,修改时间,访问时间

Delphi 给变量加引号

Delphi 用文字作为窗体的形状

Delphi图像细化处理

Delphi checkbox 透明

Delphi fmx输出彩色文本

Delphi 检测网络是否连通

Delphi xe 无法编译apk提示sdk路径问题时?sdk路径配置方法

Delphi getrandompassword 生成随机密码

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



打赏

取消

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

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

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

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

评论

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