# Import <SystemConfiguration/SCDynamicStoreCopySpecific. h>
# Import <SystemConfiguration/SCSchemaDefinitions. h>
# Import <Security/Security. h>
Void GetProxyHostNameAndPort (CFStringRef proxyEnableKey, CFStringRef proxyHostNameKey, CFStringRef proxyPortKey, NSString ** hostNamePtr, int * portPtr)
{
NSAID utoreleasepool * pool = [[NSAID utoreleasepool 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)