DelphiFAQ Home Search:

Changing the TCP/IP DNS address

 

commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.

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;

Comments:

2006-03-23, 11:14:25
anonymous from Denmark  
But.. can i get a DNS address if i dont have a domain?


-Teis
2015-02-01, 08:21:26
anonymous from Dubai, United Arab Emirates  
Was totally stuck until I read this, now back up and runinng.

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: