问题描述
有一种方法,从一个Cocoa应用程序中更改系统网络设置(具体来说,代理设置)。我发现在 / Library / Preferences / SystemConfiguration 中有一个名为 preferences.plist 的文件,它有我想要的设置,但我不知道如何让系统处理对此文件的更改而不重新启动。
Is there a way, from within a Cocoa application to change the system network settings (specifically, the proxy settings). I've found that there is a file called preferences.plist in /Library/Preferences/SystemConfiguration that has the settings I want, but I can't figure out how to get the system to process changes to this file without rebooting.
可以通过编程方式,或者至少通过启动一些命令? (这个解决方案可能只有10.5.x,我假设)
Can this be done programmatically, or at least by launching some command? (This solution would probably be 10.5.x only, I'm assuming)
由于我可以立即在系统偏好中更改这些设置,必须有一些方法,它只是eludes me ....
Since I can change these settings in System Preferences immediately, there must be some way, it just eludes me ....
谢谢!
推荐答案
框架,特别是代理字典(请参阅了解更多详情)。
You want the SystemConfiguration framework, specifically the Proxies Dictionary (see here for more details).
这篇关于以编程方式更改系统网络(代理)设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!