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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

logged on user name in vb6? 1

Status
Not open for further replies.

JonesMone

Programmer
Mar 11, 2002
10
0
0
GB
I used to pick up the user name from an environment variable in windows 95/98 but this doesnt work in win2000.
Do you know of an simple solution to finding out who is logged in to workstation?(i have some sort of solution involving reams of code calling the api, yuck)


----------------------------------------
How do people find the time to type this bit?
 
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Private Function WinUser_S() As String
Dim sBuffer As String
sBuffer = String(100, Chr$(0))

GetUserName sBuffer, 100

WinUser_S = Left$(sBuffer, InStr(sBuffer, Chr$(0)) - 1)

End Function [/b][/i][/u][sub]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 
Thanks CClint, thats a bit tidier than the solution i had!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top