- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
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.