|
|
How to get machine name?
|
|
|
|
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status:
Offline
|
|
I know I can use NSFullUserName() to get the users name. Is there an analogous way to get the name of the computer?
kman
|
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
SCDynamicStoreCopyComputerName in SystemConfiguration.framework
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status:
Offline
|
|
Originally posted by Angus_D:
SCDynamicStoreCopyComputerName in SystemConfiguration.framework
Thanks. How do I go about actually getting that information?
kman
|
|
|
|
|
|
|
|
|
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status:
Offline
|
|
Create a dynamic store, and copy it out using that function. See the headers and documentation.
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status:
Offline
|
|
Sorry. I don't know what a dynamic store is and I can't find those frameworks anywhere. Could you explain a bit more for a newbie? I haven't ventured much out of Foundation and Appkit.
kman
|
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: Feb 2001
Location: Germany
Status:
Offline
|
|
Don't worry about the store. Just pass "NULL", it'll create a temporary session for you:
NSString *hostname = (NSString *)SCDynamicStoreCopyComputerName(NULL, NULL);
does the trick.
|
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Oct 2001
Location: San Diego, CA, USA
Status:
Offline
|
|
Just remember that 1) You'll have to link in the SystemConfiguration framework, 2) You'll have to include <SystemConfiguration/SystemConfiguration.h>, and 3) You'll have to release the string obtained from that function.
|
Chuck
___
"Instead of either 'multi-talented' or 'multitalented' use 'bisexual'."
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status:
Offline
|
|
Originally posted by Chuckit:
Just remember that 1) You'll have to link in the SystemConfiguration framework, 2) You'll have to include <SystemConfiguration/SystemConfiguration.h>, and 3) You'll have to release the string obtained from that function.
Well, I think I did #2 okay, but I'm not sure how to do #1. For #2, I just did:
#import <SystemConfiguration/SystemConfiguration.h>
Here's the error I'm getting now during the build:
ld: ~/Documents/Programming/F@HMonitor/build/ [email protected]/ [email protected]/Objects-normal/ppc/FMController.o illegal reference to symbol: _SCDynamicStoreCopyComputerName defined in indirectly referenced dynamic library /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Sep 2000
Location: San Francisco
Status:
Offline
|
|
Nevermind. I found the 'Add Framework...' menu item in PB. Now it works great! Thanks for all the help.
kman
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|