Solved

Getting username on WinNT / Win95

Posted on 1998-09-01
4
213 Views
Last Modified: 2013-12-03
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.

Thanks,
Shawn
0
Comment
Question by:sgrobins
  • 2
4 Comments
 
LVL 8

Expert Comment

by:Answers2000
Comment Utility
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 ?
0
 

Expert Comment

by:ratheesh
Comment Utility
There is an SDK Function GetUserName(LPCTSTR StringPointer, DWORD* LengthofAllocatedString) which will return user name in StringPointer.
0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 50 total points
Comment Utility
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
0
 

Author Comment

by:sgrobins
Comment Utility
GetUserName worked perfectly.  Not sure how I overlooked that one, but Thanks.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now