DelphiFAQ Home Search:
General :: Programming :: Delphi :: Network
Network (local network and Internet) programming under Windows with Delphi.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Changing the TCP/IP DNS address

A Domain Name Server convert mnemonic internet addresses to their natural numeric IP addresses e.g. preview.org = 209.204.209.81

If you have a need to dynamically change your DNS servers from your program, you can do so by calling the the following

uses
   Registry;
 
 procedure SaveStringToRegistry_LOCAL_MACHINE (sKey, sItem, sVal: string);
 var
   Reg : TRegIniFile;
 begin 
   Reg := TRegIniFile.create (''); 
   Reg.RootKey := HKEY_LOCAL_MACHINE; 
   Reg.WriteString (sKey, sItem, sVal + #0); 
   Reg.Free
 end; 
 
 
 procedure SetTCPIPDNSAddresses (sIPs: string); 
 begin 
   if RunningWinNT then 
   begin 
     // 
     // if using Windows NT 
     // 
     SaveStringToRegistry_LOCAL_MACHINE (
       'SYSTEM\CurrentControlSet\Services\Tcpip\Parameters',
       'NameServer', sIPs)
   end 
   else 
   begin 
     // 
     // if using Windows 95 
     // 
     SaveStringToRegistry_LOCAL_MACHINE (
       'SYSTEM\CurrentControlSet\Services\VxD\MSTCP',
       'NameServer', sIPs)
   end 
 end;
 

Generated 8:02:01 on Sep 22, 2019