Re: Would there be an easier way to get the name of the current Network Location?
Re: Would there be an easier way to get the name of the current Network Location?
- Subject: Re: Would there be an easier way to get the name of the current Network Location?
- From: Allan Nathanson <email@hidden>
- Date: Thu, 15 Feb 2007 13:26:47 -0500
On Feb 15, 2007, at 1:16 PM, Stephane wrote:
I want to know the readable name of the current Network Location.
According to the SC header, you can get the identifier of the
current location using SCDynamicStoreCopyLocation.
OK, this gives a UUID which is User Unreadable I Dare to say.
A quick look in the SC header and in scutil gives no clues on how to
get the readable name.
So let's go to MoreSCF. Sure we find some code to get the visible
name (apparently it's MoreSCCopyUserVisibleNameOfSet).
The issue is that I don't want to integrate all the MoreSCF code
just to get access to this feature.
I can certainly pick here and there some parts of the code to do
this but I was wondering:
Isn't there an easier way to just get the readable name of the
current location?
How about the following :
SCPreferencesRef prefs;
SCNetworkSetRef set;
CFStringRef name;
prefs = SCPreferencesCreate(NULL, CFSTR("com.yourCompany.yourApp"),
NULL);
set = SCNetworkSetCopyCurrent(prefs);
name = SCNetworkSetGetName(set);
if (name == NULL) {
// no name set, use ID
name = SCNetworkSetGetSetID(set);
}
// use the name
CFRelease(set);
CFRelease(prefs);
- Allan
_______________________________________________
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