本文整理自网络,侵删。
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);begintext:=IntToStr(GetIPNumberIPV4('127.0.0.1'));end;
end.
相关阅读 >>
Delphi xe 无法编译apk提示sdk路径问题时?sdk路径配置方法
Delphi getrandompassword 生成随机密码
更多相关阅读请进入《Delphi》频道 >>