When you are testing and playing around with server solutions you sometimes have the need to control exactly where your requests are going. Maybe the host you’re trying to connect to isn’t registered in your DNS, or maybe you want to access the external IP and not the internal IP your internal DNS resolves to. We’ve all been there, and on our computers we are so happy we can edit our hosts file and take control.
What about Windows Mobile? Sure, we have the same needs here. Maybe even more here sometimes when we’re dealing with SSL certificates and we can’t press “ok” to accept the site that resolves to a different host name than the common name in the certificate. But Windows Mobile does not have a hosts file… Windows Mobile does have the functionality, but it’s buried in the registry. (Really user-friendly.)
It can be found in HKLM\Comm\Tcpip\Hosts. Do the following:
– Add a subkey which is the host name/FQDN.
– Add a Binary value ipaddr containing to hexadecimal notation of the IP address.
– Add a Binary value ExpireTime containing an expiration value. I think this is actually optional, or you can just set it to a large value – say “99 99 99 99 99 99 99”. (As in never expire basically.)
So adding www.mobilitydojo.net, resolving to 192.168.0.1 would look like this:
Unless you’re really good at hex you’ll probably have to get assistance from calc.exe computing the value for ipaddr 🙂
Deciding this was a pretty mundane chore, I thought that creating a small utility shouldn’t take too much time. Now I’m not claiming to be the guy who discovered this little gem digging through the registry, and there are other apps out there that will let you add entries to the registry. But that doesn’t prevent me from making my own implementation 🙂
There are two simple things you can do in this little utility – you can add hosts, and remove hosts. (I have hardwired the ExpireTime to equal “99 99 99 99 99 99 99”.) Given the simple interface I think you will be able to work it out without further instructions. You might be wondering what “ppp_peer” is, and what kind of record this is. It’s used by ActiveSync, (when you cradle your device), to assign an address to the device itself. Just leave this record as it is.
And as usual I must add the disclaimer that I take no responsibility if an error message occurs 🙂 (Not that I see much more than the application itself crashing as likely to happen though.)
Download (Updated 05.nov.08):
Windows Mobile Professional http://mobilitydojo.net/files/HostsFileEditPro.exe
Windows Mobile Standard http://mobilitydojo.net/files/HostsFileEditStd.exe