Re: Equivalent to Windows API 'GetUserName()'
Re: Equivalent to Windows API 'GetUserName()'
- Subject: Re: Equivalent to Windows API 'GetUserName()'
- From: Ryan Stevens <email@hidden>
- Date: Fri, 6 Jun 2003 07:43:56 -0700
On Thursday, June 5, 2003, at 06:46 PM, Andy Satori wrote:
I'm certain this is dead easy and I'm just overlooking it, but I want
to find out the current user's name from Objective C. I don't see any
foundation objects that look like they fit the bill.
In Windows, I would simply call the GetUserName() API call:
char *szUser;
DWORD cbUser = MAX_PATH;
szUser = new char[cbUser];
GetUserName(szUser, &cbUser);
printf("Current User Name: %s\n", szUser);
delete szUser;
Unfortunately I don't see an equivalent. I'm assuming I need
something from the Core Foundation to do this, but I'm not entirely
certain where to even look. Any suggestions?
If it hasn't already been said....
NSString *fullName = NSFullUserName();
NSString *shortName = NSUserName();
Found under the Foundation Functions section of the docs.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.