by Vineeth Venugopal (7 Submissions)
Category: Windows System Services
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Mon 9th June 2008
Date Added: Mon 8th February 2021
Rating: (1 Votes)
gives the username of your system
API Declarations
Private Sub Command1_Click()
Call User_Name
End Sub
Private Function User_Name() As String
Dim nName As String 'name of the logged user
Dim nBuffer As String
Dim nSize As Long
nBuffer = Space$(250)
nSize = Len(nBuffer)
If GetUserName(nBuffer, nSize) = 1 Then
nName = Trim(nBuffer)
MsgBox nName
Exit Function
End If
End Function