• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Equivalent to Windows API 'GetUserName()'
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Equivalent to Windows API 'GetUserName()' (From: Andy Satori <email@hidden>)

  • Prev by Date: RE: string encoding
  • Next by Date: Making an interpreter
  • Previous by thread: Re: Equivalent to Windows API 'GetUserName()'
  • Next by thread: Re: string encoding
  • Index(es):
    • Date
    • Thread