可能数值过大integer不能存储吧!你把integer改称int64试一下!

解决方案 »

  1.   

    winsock 现成的 api:
    inet_addr
    inet_ntoa
    注意intel的int,1.2.3.4转换成整数,前面的位数是低位,即 $04030201
    用ntohl和ntohs转换主机、网络的long和short类型
      

  2.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
      StdCtrls,winsock;type
      TForm1 = class(TForm)
        Edit1: TEdit;
        Edit2: TEdit;
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.DFM}function IPStrToInt(s:String):Integer;
    begin
      result:=inet_addr(pchar(s));
    end;function IPIntToStr(I:Integer):String;
    var
    sinaddr:in_addr;
    begin
      sinaddr.S_addr:=i;
      result:=String(inet_ntoa(sinaddr)); 
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
    showmessage(inttostr(IPStrToInt('2.1.0.0')));
    showmessage(IPIntToStr(258));
    end;end.
      

  3.   

    用ntohl和ntohs转换主机、网络的long和short类型那么为什么255.255.255.255为-1,255.255.255.254为-2
    怎样使从0.0.0.1到255.255.255.255转化后都为正数?