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

Get the user name logged the machine

Status
Not open for further replies.

medeirh

Programmer
May 22, 2002
3
BR
How can I get the user name that login the machine?
 
Option Explicit
Dim x As Long
Dim User As String
Private Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, nSize _
As Long) As Long

Private Sub Command1_Click()
Dim Test As String
Test = GetCurrentUser
Print Test
End Sub

Public Function GetCurrentUser() As String

User = Space$(500)
x = GetUserName(User, 500)

GetCurrentUser = Left(User, InStr(User, Chr(0)) - 1)

End Function Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top