static Dns_Client()
{
// Try to get system dns servers
try{
string[] retVal = new string[]{"",""};
ProcessStartInfo pInfo = new ProcessStartInfo("ipconfig","/all");
pInfo.RedirectStandardOutput = true;
pInfo.UseShellExecute = false;
pInfo.CreateNoWindow = true;
Process p = Process.Start(pInfo);
StreamReader r = p.StandardOutput;
bool secondary = false;
string line = r.ReadLine();
while(line != null){
if(line.Trim().ToLower().StartsWith("dns servers")){
// Primary dns server
retVal[0] = line.Substring(line.IndexOf(':') + 1).Trim();
line = r.ReadLine();
if(line == null){
break;
}
line = r.ReadLine();
if(line == null){
break;
}
// There is secondary dns server
if(line.Trim().IndexOf(":") == -1){
secondary = true;
retVal[1] = line.Trim();
}
break;
}
line = r.ReadLine();
}
if(secondary){
m_DnsServers = retVal;
}
else{
m_DnsServers = new string[]{retVal[0]};
}
}
catch{
}
}