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与汇编杂谈

Delphi 使用edge browser浏览器组件

Delphi中如何控制webbrowser滚动条

Delphi vcl 的 tpagecontrol 控件,实现对页签的拖动

Delphi 查找某目录下的特定文件

Delphi程序将自身可执行文件拷贝到u盘的代码

Delphi 获取 cpu 使用率的单元

Delphi 判断一个颜色是否是亮色

Delphi xe7的android应用设定wifi的有效无效

Delphi快速地删除一个目录

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



打赏

取消

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

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

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

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

评论

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