 |
 |
User Info
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Apr 2002
Status:
Offline
|
|
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
|
|
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
|
|
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.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Apr 2002
Status:
Offline
|
|
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
|
|
|
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Apr 2002
Status:
Offline
|
|
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
|
|
Well then getuid() or geteuid() should work. What errors are you getting?
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Apr 2002
Status:
Offline
|
|
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
|
|
You need to import the right header, duh. man getuid
Either that or use SystemConfiguration.
|
|
|
| |
|
|
|
 |
|
 |
|
Fresh-Faced Recruit
Join Date: Apr 2002
Status:
Offline
|
|
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
|
|
|
| |
|
|
|
 |
 |
|
 |
|
|
|
|
|

|
|
 |
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
|
|
|
|
|
|
 |
 |
 |
 |
|
 |
|