Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I access current user name? 1

Status
Not open for further replies.

JerryAttrick

Technical User
May 14, 2005
23
0
0
NZ
I have a simple application where I would like to report the date the application was previously used and who used it, when the CreateForm event occurs. Date seems easy, but how can I find out the current user name to store in the *.ini file for next time? It's obviously silly for each user to be required to enter their name each time before exiting the application.

Jerry
 
Without using a Windows API call, the easiest way would be:

Uses
SysUtils;
.
.
var
UserName : string;
.
.
UserName := GetEnvironmentVariable('USERNAME');


Hope this helps.
 
My word it certainly does help! It's magic! Thank you so much. Instinctively I thought there was a simple answer, and this certainly is as simple as they come. Bravo . . . . and it works too!!!

Sincerely,
Jerry

PS I had a bit of a search b4 this posting, and was sufficiently panicked by some of the API stuff I read: hence this enquiry. What a wondrous thing these forums are.
 
Jerry, I've just noticed this FAQ which you might want to try:

faq102-3877


Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top