On Thu, 2014-07-24 at 19:59 +0800, ?? wrote: > > Question 2: > When I run it on XP,the openconnect client will show a error > dialog?can't find Entry RegGetValueA in ADVAPI32.dll?. > so,does the openconnect6.0 client for Windows support for XP? Does this fix that? diff --git a/tun-win32.c b/tun-win32.c index c4acd92..28d530c 100644 --- a/tun-win32.c +++ b/tun-win32.c @@ -59,8 +59,8 @@ typedef intptr_t (tap_callback)(struct openconnect_info *vpninfo, char *idx, cha static intptr_t search_taps(struct openconnect_info *vpninfo, tap_callback *cb, int all) { LONG status; - HKEY adapters_key; - DWORD len; + HKEY adapters_key, hkey; + DWORD len, type; char buf[40], name[40]; char keyname[strlen(CONNECTIONS_KEY) + sizeof(buf) + 1 + strlen("\\Connection")]; int i = 0, found = 0; @@ -86,29 +86,41 @@ static intptr_t search_taps(struct openconnect_info *vpninfo, tap_callback *cb, snprintf(keyname, sizeof(keyname), "%s\\%s", ADAPTERS_KEY, buf); + status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyname, 0, + KEY_QUERY_VALUE, &hkey); + if (status) + continue; + len = sizeof(buf); - status = RegGetValue(HKEY_LOCAL_MACHINE, keyname, - "ComponentId", RRF_RT_REG_SZ, - NULL, buf, &len); - if (status || strcmp(buf, TAP_COMPONENT_ID)) + status = RegQueryValueEx(hkey, "ComponentId", NULL, &type, + (unsigned char *)buf, &len); + if (status || type != REG_SZ || strcmp(buf, TAP_COMPONENT_ID)) { + RegCloseKey(hkey); continue; + } len = sizeof(buf); - status = RegGetValue(HKEY_LOCAL_MACHINE, keyname, - "NetCfgInstanceId", RRF_RT_REG_SZ, - NULL, buf, &len); - if (status) + status = RegQueryValueEx(hkey, "NetCfgInstanceId", NULL, + &type, (unsigned char *)buf, &len); + RegCloseKey(hkey); + if (status || type != REG_SZ) continue; snprintf(keyname, sizeof(keyname), "%s\\%s\\Connection", CONNECTIONS_KEY, buf); - len = sizeof(name); - status = RegGetValue(HKEY_LOCAL_MACHINE, keyname, "Name", - RRF_RT_REG_SZ, NULL, name, &len); + status = RegOpenKeyEx(HKEY_LOCAL_MACHINE, keyname, 0, + KEY_QUERY_VALUE, &hkey); if (status) continue; + len = sizeof(name); + status = RegQueryValueEx(hkey, "Name", NULL, &type, + (unsigned char *)name, &len); + RegCloseKey(hkey); + if (status || type != REG_SZ) + continue; + found++; if (vpninfo->ifname && strcmp(name, vpninfo->ifname)) { -- dwmw2 -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/x-pkcs7-signature Size: 5745 bytes Desc: not available URL: <http://lists.infradead.org/pipermail/openconnect-devel/attachments/20140724/1387b0a8/attachment.bin>