I am afraid I am no help at all with the programming end of it but changes to the Hosts file should be immediate upon saving. They should be available for the very next DNS query. There is no need to "reload" it but using the #PRE option does pre load it for faster responses, but I know of no way of doing so after boot. It almost sounds as if your application loads the hosts file contents which is why it requires restarting.
I assume the entires do work? The hosts file has a few idiosyncrasies such as requiring a carriage return at the end of each line for it to work.
http://msmvps.com/blogs/ro
Main Topics
Browse All Topics





by: DasDirectorPosted on 2008-07-10 at 07:00:44ID: 21973465
Here is the C# code to refresh DNS that is called after the hosts file is resaved -
s proc = new System.Diagnostics.Process ();
System.Diagnostics.Proces
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = "ipconfig";
proc.StartInfo.Arguments = "/flushdns";
proc.Start();