以编程方式检索OSX网络/代理配置值 [英] Programmatically Retrieve OSX Network/Proxies configuration values

查看:143
本文介绍了以编程方式检索OSX网络/代理配置值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑到我的应用程序具有当前登录的管理员用户的用户ID和密码,是否可以从OSX网络设置检索配置值?特别感兴趣的是高级/代理标签内容。

Considering my application has the user ID and Password for the admin user currently logged in, is it possible to retrieve the configuration values from the OSX Network settings? Particularly interested in the "Advanced/Proxies" tab content.

推荐答案

这是一个从OSX网络设置获取PAC URL字符串的示例。

Did it with the settings API. Here's an example to fetch the PAC URL string from the OSX Network Settings.

static char url[257] = {0};

NSDictionary * proxies = (NSDictionary *)SCDynamicStoreCopyProxies(NULL);
NSString * pacURL = [proxies objectForKey:(NSString *)kSCPropNetProxiesProxyAutoConfigURLString];

if (NULL != pacURL)
{
    strncpy((char*) (&(url)[0]), 
            [pacURL cStringUsingEncoding:NSASCIIStringEncoding],
            sizeof(url));
}
return url;

这篇关于以编程方式检索OSX网络/代理配置值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆