Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > User Info

User Info
Thread Tools
Fresh-Faced Recruit
Join Date: Apr 2002
Status: Offline
Reply With Quote
Apr 13, 2002, 04:57 AM
 
I was looking for a little code snippet that could help identify who the user is in OS X.
     
Grizzled Veteran
Join Date: Sep 2000
Location: Springfield, MA
Status: Offline
Reply With Quote
Apr 13, 2002, 11:30 AM
 
Originally posted by Sid23Nova:
<STRONG>I was looking for a little code snippet that could help identify who the user is in OS X.</STRONG>
Try this
We hope your rules and wisdom choke you / Now we are one in everlasting peace
-- Radiohead, Exit Music (for a film)
     
Mac Elite
Join Date: Feb 2001
Location: Vancouver, WA
Status: Offline
Reply With Quote
Apr 13, 2002, 05:37 PM
 
If you're writing a Cocoa app (or Foundation command-line tool), use this:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>NSString *NSUserName(void)</font>[/code]
Found in NSPathUtilities.h, I believe.
Rick Roe
icons.cx | weblog
     
Fresh-Faced Recruit
Join Date: Apr 2002
Status: Offline
Reply With Quote
Apr 14, 2002, 09:48 PM
 
Originally posted by Sid23Nova:
<STRONG>I was looking for a little code snippet that could help identify who the user is in OS X.</STRONG>
I suppose i should clarify, I was trying to get the current user's name in OS X in a carbon application. thanks for the reply, but neither of the two options worked in the program, do you guys have any other ideas??????
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Apr 16, 2002, 01:01 PM
 
CFM or Mach-O?
     
Fresh-Faced Recruit
Join Date: Apr 2002
Status: Offline
Reply With Quote
Apr 16, 2002, 07:19 PM
 
Originally posted by Angus_D:
<STRONG>CFM or Mach-O?</STRONG>
Mach-O
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Apr 16, 2002, 07:30 PM
 
Well then getuid() or geteuid() should work. What errors are you getting?
     
Fresh-Faced Recruit
Join Date: Apr 2002
Status: Offline
Reply With Quote
Apr 16, 2002, 09:40 PM
 
Originally posted by Angus_D:
<STRONG>Well then getuid() or geteuid() should work. What errors are you getting?</STRONG>

They seem not to exist in the API, it gives me an undeclared function error, which is the same thing as it saying that it doesn't recognize the function, i think.....
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Apr 17, 2002, 12:59 PM
 
You need to import the right header, duh. man getuid

Either that or use SystemConfiguration.
     
Fresh-Faced Recruit
Join Date: Apr 2002
Status: Offline
Reply With Quote
Apr 18, 2002, 11:33 PM
 
thanks

I found another, sort of simpler, way to get it through CSCopyUserName(true), which returns a CSStringRef of the login name, which is pretty cool, actually.

Thanks again
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:44 AM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2