• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 226
  • Last Modified:

Getting username on WinNT / Win95

I have a program and need to get the current user that is logged in on the WinNT or Win95 machine.  I am using ILOG as the API.  Is there an easy way to get the user information.  I tried using the USER_INFO_10 struct, but was unsuccessful. If this is the method of choice, can someone give a quick example on how to use the struct properly.

  • 2
1 Solution
Can't you use GetUserName

USER_INFO_10 structure is typically used with NetUserEnum API which enumerates all user accounts on a server.

Exactly what information do you need about the current user ?
There is an SDK Function GetUserName(LPCTSTR StringPointer, DWORD* LengthofAllocatedString) which will return user name in StringPointer.
ratheesh -
I thought I said that yesterday <g>, maybe there's an echo in here.

sgrobins -
GetUserName will give you the account name of the current user.  Use LookupAccountName to find further information on that user.  
I think this is enough for you ?  If it's not enough post further comments telling us what else you need.

BTW NetUserEnum gives you Unicode strings back.  So if you stick to this funciton, you either need to compile you app as Unicode OR to convert the returned strings into 8 bit character set
sgrobinsAuthor Commented:
GetUserName worked perfectly.  Not sure how I overlooked that one, but Thanks.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now