[Win32] Getting user name (in John Smith form, not jsmith)

Started by
4 comments, last by Pipo DeClown 19 years, 4 months ago
Like the title says, does anyone know what Win32 API functions I would use to get the current user name? I need it in formal format, like John Smith, as oposed to a user-id format like jsmith. Thanks
Rate me up.
Advertisement
What do you mean exactly? You can simply use a windows edit box and use GetDlgItemText to read the entered text.
----------------------------------------------------"Plant a tree. Remove a Bush" -A bumper sticker I saw.
Quote:Original post by tHiSiSbOb
What do you mean exactly? You can simply use a windows edit box and use GetDlgItemText to read the entered text.


He probably meant the Windows Register.


OP: Try doing a Google search on the Windows Register, where it's contained. (Somewhere along CURRENT_USER?)
Check out GetUserNameEx in the MSDN!

char name[256];ULONG nSize = 256;GetUserNameEx(NameDisplay , name, &nSize);


Hope that helps!
Windows registry.

Call NetUserGetInfo() with a level of 2 after you get the current username with GetUserName().

Special thanks: google groups.

That's for NT. For 9x you'll need a completely different way I'm afraid, look around. GetUserNameEx() is 2k up and only I think.
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis
Quote:Original post by antareus
Windows registry.

[grin]

This topic is closed to new replies.

Advertisement