Adding an host programmatically (name resolution under Windows)
- by Tanelorn
I would like to programmatically add to Windows a name / IP association so that this name can be resolved locally. This does not have to be persisted between reboots.
The only way I now is to add an entry to the "hosts" file, but this feels hacky especially since I would like to automate this.
Is there any way to do this using a command-line tool or a Win32 API? Perhaps by addind an entry to Windows DNS cache or something similar?
Oh, and please state if this solution is Vista-compatible.
Regards.
Edit : Thanks, guy. Sadly, all of your answers indeed involve DNS or other servers. I was looking for a purely local solution which would work on a "standard" Windows installation. Such a thing does not seem to exist, though.