我试图在OS X 10.10上以编程方式配置代理。 scutil --proxy 显示正确的设置,系统实际使用它们,但新设置不会出现在网络首选项的代理选项卡上(在系统偏好设置中)。
SCDynamicStoreRef dynamicStore = SCDynamicStoreCreate(NULL, CFSTR(APP_NAME), NULL, NULL);
CFDictionaryRef ipv4key = SCDynamicStoreCopyValue(dynamicStore, CFSTR("State:/Network/Global/IPv4"));
CFStringRef primaryServiceId = CFDictionaryGetValue(ipv4key, CFSTR("PrimaryService"));
CFStringRef primaryServicePath = CFStringCreateWithFormat(NULL, NULL, CFSTR("Setup:/Network/Service/%@/Proxies"), primaryServiceId);
CFDictionaryRef proxySettings = SCDynamicStoreCopyValue(dynamicStore, primaryServicePath);
//clone currnt values for update new values
CFMutableDictionaryRef mutableProxySettings = CFDictionaryCreateMutableCopy(NULL, 0, proxySettings);
然后为我做的每个值 CFStringRef host = ...;
CFDictionaryReplaceValue(mutableProxySettings, kSCPropNetProxiesHTTPProxy, host);
然后
Boolean success = SCDynamicStoreSetValue(dynamicStore, primaryServicePath, mutableProxySettings);
设置已更新,但不会显示在代理选项卡上如何让它们出现在那里?