summaryrefslogtreecommitdiff
path: root/ares_gethostbyname.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-09-26 18:20:58 (GMT)
committerDaniel Stenberg <daniel@haxx.se>2004-09-26 18:20:58 (GMT)
commit2bf866b0ce6084e28af061d68bbc351b3be55e84 (patch)
tree7e8ac4d57a5c5e6ad224ad2e764945a3bd5320b6 /ares_gethostbyname.c
parentdb2efff373dcffabfd1f94eb689127aee8a733f5 (diff)
downloadc-ares-2bf866b0ce6084e28af061d68bbc351b3be55e84.zip
c-ares-2bf866b0ce6084e28af061d68bbc351b3be55e84.tar.gz
c-ares-2bf866b0ce6084e28af061d68bbc351b3be55e84.tar.bz2
Dominick Meglio host file path discovery patch for windows
Diffstat (limited to 'ares_gethostbyname.c')
-rw-r--r--ares_gethostbyname.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/ares_gethostbyname.c b/ares_gethostbyname.c
index b39d53b..decac55 100644
--- a/ares_gethostbyname.c
+++ b/ares_gethostbyname.c
@@ -220,15 +220,25 @@ static int file_lookup(const char *name, struct hostent **host)
int status;
#ifdef WIN32
-
char PATH_HOSTS[MAX_PATH];
if (IsNT) {
- GetSystemDirectory(PATH_HOSTS, MAX_PATH);
- strcat(PATH_HOSTS, PATH_HOSTS_NT);
- } else {
+ char tmp[MAX_PATH];
+ HKEY hkeyHosts;
+
+ if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, WIN_NS_NT_KEY, 0, KEY_READ, &hkeyHosts)
+ == ERROR_SUCCESS)
+ {
+ DWORD dwLength = MAX_PATH;
+ RegQueryValueEx(hkeyHosts, DATABASEPATH, NULL, NULL, tmp,
+ &dwLength);
+ ExpandEnvironmentStrings(tmp, PATH_HOSTS, MAX_PATH);
+ RegCloseKey(hkeyHosts);
+ }
+ }
+ else
GetWindowsDirectory(PATH_HOSTS, MAX_PATH);
- strcat(PATH_HOSTS, PATH_HOSTS_9X);
- }
+
+ strcat(PATH_HOSTS, WIN_PATH_HOSTS);
#elif defined(WATT32)
extern const char *_w32_GetHostsFile (void);