怎么取windows的DNS,设置Ip地址,DNS???
给出源码!!!

解决方案 »

  1.   

    function GetDNS: string;
    {$IFDEF LINUX}
    var
      l: TStringList;
      n: integer;
    begin
      Result := '';
      l := TStringList.Create;
      try
        l.LoadFromFile('/etc/resolv.conf');
        for n := 0 to l.Count - 1 do
          if Pos('NAMESERVER', uppercase(l[n])) = 1 then
          begin
            if Result <> '' then
              Result := Result + ',';
            Result := Result + SeparateRight(l[n], ' ');
          end;
      finally
        l.Free;
      end;
    end;
    {$ELSE}
    const
      NTdyn = 'System\CurrentControlSet\Services\Tcpip\Parameter  s\Temporary';
      NTfix = 'System\CurrentControlSet\Services\Tcpip\Parameter  s';
      W9xfix = 'System\CurrentControlSet\Services\MSTCP';
    begin
      Result := GetDNSbyIpHlp;
      if Result = '...' then
        if Win32Platform = VER_PLATFORM_WIN32_NT then
        begin
          Result := ReadReg(NTdyn, 'NameServer');
          if result = '' then
            Result := ReadReg(NTfix, 'NameServer');
        end
        else
          Result := ReadReg(W9xfix, 'NameServer');
    end;
    {$ENDIF}
      

  2.   

    搜一下,很多http://search.csdn.net/Expert/topic/1985/1985953.xml?temp=.5817987
    http://search.csdn.net/Expert/topic/677/677230.xml?temp=.7453882
      

  3.   

    可以使用 IP Helper API