delphi IPNumberIPV4  
官方Delphi 学习QQ群: 682628230(三千人)
频道

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.

推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.035321950912476 seconds