How to change the system proxy configuration ?
How to change the system proxy configuration ?
- Subject: How to change the system proxy configuration ?
- From: Andy <email@hidden>
- Date: Mon, 25 Aug 2008 10:31:33 +0800
Hi, all
I want to change the system proxy configuration with my app. But I
failed, my code follows below.
Anyone could give me some suggestions or point out some problems in
this code will be appreciated.
Thanks for your time.
==========================================================
SCPreferencesRef session;
session = SCPreferencesCreate(nil, CFSTR("ProgName"), nil);
if (!SCPreferencesLock(session, TRUE))
printf("lock preference error!");
CFStringRef path;
// My OS is Mac OS X 10.5.3 , what's the problem with this "proxy
configuration path" ?
path = CFStringCreateWithCString(NULL, "/Network/Service/0/Proxies",
kCFStringEncodingASCII);
// Actually , I got a null path here... I guess it's caused by path above.
CFDictionaryRef aProxy = SCPreferencesPathGetValue(session, path);
if(!aProxy)
printf("dictionary ref return null");
CFMutableDictionaryRef dict = CFDictionaryCreateMutableCopy(NULL, 0, aProxy);
CFDictionarySetValue(dict, kSCPropNetProxiesHTTPSProxy,CFSTR("9.181.65.200"));
int port = 8000;
CFDictionarySetValue(dict,
kSCPropNetProxiesHTTPSPort,CFNumberCreate(NULL,kCFNumberLongType,&port));
int enable = 1;
CFDictionarySetValue(dict,
kSCPropNetProxiesHTTPSEnable,CFNumberCreate(NULL,kCFNumberLongType,&enable));
SCPreferencesPathSetValue(session, path, dict);
SCPreferencesCommitChanges(session);
SCPreferencesApplyChanges(session);
SCPreferencesUnlock(session);
======================================================================
Andy,
Best Regards.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden