标签:http io ar os sp on cti ad ef
#import <SystemConfiguration/SCDynamicStoreCopySpecific.h>
#import <SystemConfiguration/SCSchemaDefinitions.h>
#import <Security/Security.h>
void GetProxyHostNameAndPort((CFStringRef proxyEnableKey, CFStringRef proxyHostNameKey, CFStringRef proxyPortKey, NSString **hostNamePtr, int *portPtr)
{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
//Get general proxy info
CFDictionaryRef proxyInfoCPtr = SCDynamicStoreCopyProxies(NULL);
NSDictionary *proxyInfo = (__bridge NSDictionary *) proxyInfoCPtr;
NSNumber *proxyEnabled = proxyInfo[(__bridge NSString *)proxyEnableKey];
//Check proxy enabled?
if (![proxyEnabled intValue])
{
*hostNamePtr = nil;
*portPtr = 0;
[pool release];
return;
}
*hostNamePtr = proxyInfo[(__bridge NSString *)proxyHostNameKey];
NSNumber *portNumber = proxyInfo[(__bridge NSString *)proxyPortKey];
*portPtr = [portNumber intValue];
[pool release];
return;
}
-------------------------------------------------------------
GetProxyHostNameAndPort(kSCPropNetProxiesHTTPEnable, kSCPropNetProxiesHTTPProxy, kSCPropNetProxiesHTTPPort, hostName, port);
GetProxyHostNameAndPort(kSCPropNetProxiesHTTPSEnable, kSCPropNetProxiesHTTPSProxy, kSCPropNetProxiesHTTPSPort, hostName, port);
Get host name and port(Object-c)
标签:http io ar os sp on cti ad ef
原文地址:http://www.cnblogs.com/sz-leez/p/4080153.html