Adding an host programmatically (name resolution under Windows)
Posted
by Tanelorn
on Stack Overflow
See other posts from Stack Overflow
or by Tanelorn
Published on 2009-03-17T07:09:16Z
Indexed on
2010/03/20
21:01 UTC
Read the original article
Hit count: 303
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.
© Stack Overflow or respective owner