• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to change the system proxy configuration ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: How to change the system proxy configuration ?
      • From: Quinn <email@hidden>
    • Re: How to change the system proxy configuration ?
      • From: Jaime Magiera <email@hidden>
  • Prev by Date: Re: CFSocketCreateRunLoopSource crashes
  • Next by Date: Re: How to change the system proxy configuration ?
  • Previous by thread: Re: CFSocketCreateRunLoopSource crashes
  • Next by thread: Re: How to change the system proxy configuration ?
  • Index(es):
    • Date
    • Thread