var f1:textfile;
    s1:string;
asignfile(f1,'c:\ip.txt');
reset(f1);
readln(f1,s1);
s1即为ip 的值

解决方案 »

  1.   

    写ini更方便呀
    with Tinifile.create('ipaddress.ini') do
    begin
    writestring('application','ipaddress','127.0.0.1');
    end;
      

  2.   

    //可以用一个打开文件文本框,这样交互性更好些
    var 
      F: TextFile; {F为你所创建的文本文件} 
      S: string;   {S为你所要的IP地址字符串}
    begin                    
      if OpenDialog1.Execute then            { Display Open dialog box }
      begin
        AssignFile(F, OpenDialog1.FileName); { File selected in dialog }
        Reset(F);
        Readln(F, S);                        { Read first line of file }
        Edit1.Text := S;                     { Put string in a TEdit control }
        CloseFile(F);
      end;
    end;